Model Ops

AI model studio

Launch Google Colab training runs, inspect the reusable case-study modules, and sync weights back to the Raspberry Pi control stack.

🤖

Colab quick-start

Recommended steps before launching any SmartPlants notebook run.

  • Upload the latest sensor CSV exports to Colab (mount Google Drive or drag-drop into /content/data).
  • Clone or sync this repository inside Colab so the case-study modules stay in sync with the web dashboard.
  • Select the training notebook below, choose the model class you want to run, and start the training cell blocks.
  • Export trained weights (PyTorch .pt or JSON thresholds) back to Firebase or local storage for deployment.

Environment setup

Install the same dependencies used by the Raspberry Pi controller.

pip install -r requirements.txt

Inside Colab, run the command above in a shell cell (!pip install -r requirements.txt). For GPU experiments add torch or torchvision wheels pinned to Colab's runtime.

Colab workflows

Open Colab
Notebook

SmartPlant Colab Training

Notebook orchestrating data upload, preprocessing, and fine-tuning for the case-study models directly inside Google Colab.

  • Sync latest sensor exports to Colab's `/content/data` directory
  • Select desired case study module to import and instantiate
  • Persist trained weights back to Firebase or local storage
Download notebook Path: ai model/smartplant_colab_training.ipynb

Model library

Random Forest

Water Stress Classification

Tree-based baseline that maps engineered sensor features to four irrigation stress labels using scikit-learn's RandomForestClassifier.

  • Leverages lagged soil, climate, and light trends via SensorDataPreprocessor
  • Class-balanced training through RandomForest class_weight
  • Exports feature importance scores for agronomic explainability
Download code Module: ai model/case_study_classification.py
LSTM

Water Stress Forecasting

Sequence model that forecasts upcoming stress states from SmartPlant telemetry windows with a PyTorch LSTM core.

  • Sliding window builder converts per-plant panels into training batches
  • Inverse-frequency class weights mitigate imbalanced agronomic labels
  • Designed for multi-step scheduling assistance via probability outputs
Download code Module: ai model/case_study_forecasting.py
Vision + Sensors

Multimodal Stress Estimation

CLIP-inspired architecture that fuses RGB+NIR crop snapshots with SmartPlant telemetry embeddings to classify stress levels.

  • Lightweight CNN encoder for 4-channel canopy imagery
  • LSTM-based sensor encoder aligned with sequence preprocessing
  • Contrastive objective to align visual and sensor modalities
Download code Module: ai model/case_study_multimodal.py

Deployment hand-off

After training, drop your artifacts into the Raspberry Pi workspace (static/models/ or Firebase storage) and refresh the dashboard. The scheduler picks up new thresholds on the next sync cycle.

Need automation later? Expose a new endpoint in app.py that ingests model metadata and restarts the inference workers without downtime.