AgroHealth turns a photo of a plant leaf into a diagnosis and plain-language advice: three CNNs each name the disease, and the majority wins. I wrote all of the code in about ten days in April 2025, and it stopped as a working prototype that was never deployed.
What it is
A Streamlit app for farmers. You upload one or more leaf photos and get back the crop and disease, how each model voted, and advice on causes, treatment and next steps. Field photos can also come from an ESP32-CAM that uploads to a Google Drive folder.
- CaptureESP32-CAM at 800×600, or a phone upload
- CropField photos: a leaf classifier and OpenCV cut out single leaves
- VoteThree CNNs at 128×128; the majority wins
- AdviseGemini explains causes and next steps
Why it mattered
Crop disease is usually caught by someone walking the rows and recognising the symptoms. That takes time and expertise, and by the time a disease is obvious it has often spread to the next plants. A cheap camera and a phone-friendly app could give a small farm a first opinion in seconds, and help treat only the plants that need it.
What I built
We were a team of two. Saksham Chauhan wrote the project's documentation; I wrote all of the code: the training notebooks, the models, the cropping pipeline and the app.
The models. I merged several public plant-disease datasets into 190,025 training and 50,125 validation images: 107 classes, 79 of them diseases and 28 healthy, across 27 crops. Each model is a plain Keras CNN trained from scratch at 128 × 128: five blocks of 3×3 convolutions, 32 to 512 filters, then a large dense layer and a 107-way softmax.
The vote. One network is easy to fool with an odd angle or bad light, so the app runs three and takes a hard majority. The page shows each model's answer and confidence beside the result, so a split vote is visible.
The field pipeline. A script pulls ESP32-CAM images from Drive with a read-only service account. A small classifier decides whether a photo shows one leaf or a bunch, and OpenCV cuts bunches apart with a blur, an Otsu threshold and contours.
The advice. Only the final class goes to Gemini, with a prompt that asks for causes, treatment and next steps in a farmer's terms.
- validation accuracy, one CNN
- 88.9%
- classes across 27 crops
- 107
- training images
- 190k
- models voting
- 3
What was hard
Field photos looked nothing like the training data. The datasets show one clean leaf; a camera on a farm sees bunches on messy backgrounds. I trained a leaf-or-bunch classifier on 4,506 images and split bunches with OpenCV contours. It is crude: it only works when the leaves stand out from what's behind them.
Training was slow. One pass over 190,025 images took about 15 minutes on my machine, so each model got 11 epochs. The run I recorded reached 88.9% validation accuracy and 93.0% on its own training set. A pretrained backbone would have learned faster than training from scratch, but I didn't have the time to switch.
The hardware fought back. Our ESP32-CAM setup couldn't produce JPEGs, so images were captured as RGB565 and converted before upload. One module's camera port failed and had to be replaced.
I chose a hard vote over averaging the models' probabilities because it is easy to show on screen. Soft voting was next on the list.

Where it landed
AgroHealth reached a working prototype in ten days and stopped there. It was never deployed, and I haven't touched it since April 2025.
The gaps are real. The three-model vote was never scored on a held-out test set, so 88.9% is one model's number, not the app's. The cropped field images don't feed the detection page on their own. The experimental Gemini model it calls has since been retired, so the advice step needs a new model name.
If I picked it up again, I'd fine-tune one pretrained network on cleaned-up labels, measure the vote against it on a proper test split, wire the field crops straight into the models, and ship it as a small phone-first web app.
