Skip to content
Laviyx Learn

Try

Final-year project

Plant Leaf Disease Detection with Deep Learning

A PyTorch image classifier that identifies plant diseases from photos of leaves using transfer learning, evaluated carefully, with a web app that takes a photo and says when it is unsure.

Advanced 8–12 weeks 2–4 studentsUpdated

PythonPyTorchtorchvisionA pretrained CNN such as ResNet or MobileNetFastAPI or Streamlit

The problem

Plant diseases can destroy a large part of a harvest, and spotting them early helps farmers act in time. Many diseases show visible patterns on leaves. This project trains a deep learning model to recognise them from photos.

A widely used public dataset is PlantVillage, with about 54,000 leaf images in 38 classes of healthy and diseased leaves across 14 crops. Most of its photos were taken on plain backgrounds, so an important part of this project is testing how well the model works on real photos from a field.

Features to build

  • Load the dataset with torchvision and split it into training, validation and test sets
  • Fine-tune a pretrained CNN (transfer learning) instead of training from scratch
  • Use data augmentation: flips, rotations, crops and colour changes
  • Report accuracy, per-class precision and recall, and a confusion matrix on the test set
  • Collect at least 100 of your own field photos and report results on them separately
  • A web app: upload or take a photo and see the top predictions with confidence
  • Say 'not sure, please consult an expert' when confidence is below a threshold

Build plan

  1. 1

    Prepare the data

    Download the dataset, check the class counts, and split it with a fixed random seed. Make sure near-identical images of the same leaf do not end up in both training and test sets.

  2. 2

    Set up transfer learning

    Load a pretrained model, replace its last layer with one for your number of classes, and first train only that layer.

  3. 3

    Fine-tune

    Unfreeze more layers and train with a lower learning rate, with augmentation, while watching the validation loss for overfitting.

  4. 4

    Evaluate on two test sets

    Report results on the dataset's test split and on your own field photos, and study the mistakes with the confusion matrix.

  5. 5

    Build the app

    Save the trained model, load it in a FastAPI or Streamlit app, apply the same preprocessing as training, and add the confidence threshold.

Learn these first

Each part of the project is taught in one of these free lessons.

Make it stand out

  • Show a heat map (Grad-CAM) of which part of the leaf the model looked at
  • Make the model small enough to run on a phone with a mobile-friendly architecture
  • Add short care advice for each disease, taken from a reliable agricultural source
  • Compare two or three architectures for accuracy, size and speed

Viva and interview questions

Try to answer each one aloud before you open it.

  • What is transfer learning and why use it here?

    Starting from a model already trained on a large image dataset and adapting it to your task. The early layers already detect edges, textures and shapes, so the model needs far less data and training time than learning from scratch.

  • Why does accuracy drop on real field photos?

    Most dataset photos show one leaf on a plain background in good light. Field photos have soil, other leaves, shadows and blur. The model learned from a narrower kind of image than it now sees, which is called a distribution shift.

  • Why use data augmentation?

    Random flips, rotations, crops and colour changes create varied versions of each image, so the model learns the disease patterns instead of memorising exact photos. It reduces overfitting.

  • Why add a confidence threshold?

    The model always picks some class, even for a photo of something else. If the top probability is low, it is better to say it is unsure than to give a wrong diagnosis that could lead to the wrong treatment.

  • How do you know the model is not overfitting?

    Track the training and validation loss during training. If training loss keeps falling while validation loss rises, the model is memorising. Augmentation, early stopping and freezing more layers help.

What to put in your project report

  1. Abstract: the problem, your solution and the result in one paragraph.
  2. Introduction and problem statement: who has the problem and why it matters.
  3. Requirements: the features (functional) and qualities such as speed and security (non-functional).
  4. Design: architecture diagram, database tables or data flow, and screen layouts.
  5. Implementation: the main modules and the most interesting code, explained.
  6. Testing: the test cases you ran, with inputs, expected and actual results.
  7. Results: screenshots or numbers that show the project working.
  8. Conclusion and future scope: what you achieved and what you would add next.

Your college may give its own format. Follow that first, and use this list to check nothing is missing.

All project ideas →