Phenology/Code/Supervised_learning/resnet/specs/1-phenology-classifier/quickstart.md
2025-11-06 14:16:49 +01:00

1.4 KiB

Quickstart: ResNet Phenology Classifier

Date: 2025-11-04 Feature: specs/1-phenology-classifier/spec.md

Prerequisites

  • Python 3.11+
  • GPU with CUDA support (recommended)
  • 4GB+ RAM
  • Dataset with plant images and labels CSV

Installation

  1. Clone the repository and checkout the feature branch:

    git checkout 1-phenology-classifier
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Prepare your dataset:

    • Place images in data/images/
    • Create data/labels.csv with columns: image_path, phase

Training

Run the training script:

python src/train.py --data_dir data/ --epochs 50 --batch_size 32

This will:

  • Load the dataset
  • Train ResNet50 on your data
  • Save the model to models/phenology_classifier.pth

Evaluation

Evaluate the trained model:

python src/evaluate.py --model_path models/phenology_classifier.pth --data_dir data/

This outputs accuracy, F1-score, and per-class metrics.

Inference

Classify a new image:

python src/inference.py --model_path models/phenology_classifier.pth --image_path path/to/image.jpg

Or start the API server:

python -m uvicorn src.api:app --reload

Then POST to http://localhost:8000/classify with image file.

Expected Results

  • Training time: ~30 minutes on GPU
  • Accuracy: >90% on validation set
  • Inference time: <1 second per image