Skip to content

kavishkartha05/Climate-Stack-Hackathon

Repository files navigation

PlantDoc model reproduction

Classification setup from PlantDoc: A Dataset for Visual Plant Disease Detection (CoDS-COMAD 2020).
Dataset: pratikkayal/PlantDoc-Dataset.

1. Dataset

Clone the dataset so that train/ and test/ live under data/PlantDoc-Dataset/:

mkdir -p data && cd data && git clone https://github.com/pratikkayal/PlantDoc-Dataset.git
  • data/PlantDoc-Dataset/train/ — one subfolder per class
  • data/PlantDoc-Dataset/test/ — same class subfolders

2. Install dependencies

pip install -r requirements.txt

3. Train

python -m plantdoc.train --model VGG16 --epochs 50

Other models: InceptionV3, InceptionResNetV2:

python -m plantdoc.train --model InceptionResNetV2 --epochs 50

Checkpoints are saved under outputs/ (e.g. outputs/vgg16_plantdoc.keras).

Train in the cloud

Upload notebooks/plantdoc_train_colab.ipynb to Google Colab, set runtime to T4 GPU, and run all cells. Download the .keras file and the .weights.h5 file from the notebook.

Using the trained model (inference)

Put vgg16_plantdoc.weights.h5 in the project root. Optionally add class_names.json for readable labels.

python -m plantdoc.predict vgg16_plantdoc.weights.h5 path/to/leaf.jpg --classes class_names.json

Example output:

Prediction: Tomato leaf bacterial spot
Confidence: 87.32%

FastAPI backend

Put vgg16_plantdoc.weights.h5 and optionally class_names.json in the project root.

pip install -r requirements.txt
uvicorn main:app --reload
  • POST /predict — upload a leaf image (form field file). Returns label, confidence, all_classes.
  • GET /health — check that the model is loaded.

Example:

curl -X POST http://127.0.0.1:8000/predict -F "file=@data/PlantDoc-Dataset/test/Apple leaf/4120978-single-green-leaf-of-apple-tree.jpg"

Docs: http://127.0.0.1:8000/docs

Reference

About

nikhil, vivek, and i built something

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors