There is a sentence on our plant disease project page that I would defend before any other. It says a model can reach 99 per cent on the PlantVillage dataset and still fall sharply on real photos with soil, hands and other leaves in the frame. It is on the page because it is the one thing a student of this project must understand before the viva, and the rest of the project is arranged around it.
The student’s problem, in plain words
You want a plant disease detection project using machine learning that looks serious and that you can explain. Search results for it are mostly journal papers, review articles and a couple of project-sale pages. They show you that it can be done. They do not tell you how to explain a number to a panel that has seen a hundred of these.
Picture a final year student who trains a model, gets a very high accuracy on the first run and walks into the viva proud. This is a made-up student. The first question is not about the architecture. It is the one our question bank calls the single most common ML viva trap: “Your accuracy is high. Why is accuracy the wrong metric here?” Then come “where did your dataset come from?” and “how did you split train and test?” All three are really asking whether the high number means anything.
Chapter one: start from a pretrained network
The project page builds on a pretrained convolutional network, MobileNetV2 or EfficientNetB0 trained on ImageNet, used as a feature extractor. You replace its classification head with a small dense layer for your disease classes. You train the new head first with the base frozen, and then unfreeze the top layers and fine-tune at a low learning rate.
Why freeze first? The new head starts with random weights, and its large early gradients would wreck the pretrained features. This is a good viva answer because it is an explanation of ordering, not a definition. Images are resized to 224 by 224 and normalised the way the base network expects. Getting that preprocessing identical at training and at prediction time is one of those details that quietly breaks the demo.
Chapter two: the dataset and the gap
According to the project page, the two datasets that matter are PlantVillage, about 54,000 leaf images across 38 classes of 14 crops, and PlantDoc, about 2,600 photos taken in real fields. PlantVillage photos are single leaves on a plain background. A model trained only on them learns that world very well, and it has never seen soil or a thumb.
This is the turning point. The project does not hide the gap. It measures it: train on PlantVillage, then test on PlantDoc, and put both scores in the report. The drop is a finding, not a failure. When the panel asks “why is your accuracy lower on PlantDoc?”, the answer is already in your own results table. You then narrow the gap with augmentation: random flips, rotations, zoom and brightness changes, so the model learns the disease rather than the pose or lighting of the photo.
Also check for leakage. If near-identical photos of the same leaf end up in both training and test sets, your score is inflated before you start. Split carefully, and say how.
Chapter three: saying “I am not sure”
A softmax output always picks a class, even for a photo of a cat. If you send a non-leaf image to a model you built, it will name a disease with a straight face. The project handles this with a confidence threshold. If the best probability is below it, the API returns a not-sure response and asks for a clearer leaf photo. It also returns the top three predictions with probabilities, so a close call looks like a close call.
There is one more issue the page names: class imbalance. Some diseases have many times more images than others. Class weights during training and per-class recall in the report stop the rare diseases from being ignored, and they let you answer the follow-up to a high accuracy number, which is why accuracy alone is the wrong metric here.
Chapter four: serving it
The trained model is saved and served by FastAPI, with a React page for capture or upload. A photo goes through the same preprocessing, and the model returns the top three classes. Keep an eye on model size and load time when you deploy. The free deployment guide covers where a small model service can live without cost.
What I would do again
- Use transfer learning with MobileNetV2 or EfficientNetB0, not a CNN from scratch.
- Freeze the base, train the head, then fine-tune the top layers at a low learning rate.
- Test on a second dataset of real field photos and report both scores.
- Augment with flips, rotations, zoom and brightness.
- Report per-class recall, not only overall accuracy.
- Return top three predictions, and a not-sure message under a confidence threshold.
- Write the lab-versus-field gap into your limitations chapter before the panel finds it.
Viva answers to rehearse
What is transfer learning: reuse a network trained on a large dataset and retrain only the last layers. Why freeze the base first: to protect pretrained features from large early gradients. What does augmentation do: it reduces overfitting by showing the model altered copies. How does the app handle a non-leaf photo: a confidence threshold and a not-sure answer. Practise the rest with the machine learning section of the viva question bank, which has eleven questions on data provenance, splits, metrics and bias.
The project class for it, covering the training notebook, the FastAPI service and the React interface, built together, is on the plant disease detection page. For other ML titles with the same level of detail, see the AI projects guide.