Plant leaf disease detection with a camera and AI
Farmers often spot leaf disease too late or spray the wrong pesticide. A camera that photographs a leaf and names the likely disease and remedy, working offline in the field, helps them act early.
- Parts
- ₹9,380
- Build
- 14 weeks
- Board
- Raspberry Pi 4
- Objectives
- 4
Block diagram
- CameraPhotographs the leaf
- Raspberry Pi 4Runs the trained model
- Ring lightEven lighting for every photo
- Result pageShows disease, confidence and remedy
Objectives
- To train an image classifier (transfer learning on MobileNet) for at least five diseases of one crop plus healthy leaves.
- To run it on the Raspberry Pi in under 1 s per leaf, offline.
- To show the disease, confidence and a remedy from an agriculture department source.
- To report accuracy on 100 field photos not used in training.
Parts and specifications
- Raspberry Pi 4 Model B (4 GB)Quad Cortex-A72 1.8 GHz, 4 GB RAM, CSI camera port, 40-pin GPIO (3.3 V)₹5,200Buy
- Raspberry Pi 4 USB-C 15 W supply₹600
- Case, button and leaf holder₹300
Total about ₹9,380 at typical online prices. Tap a part for its pinout and datasheet notes.
Design calculations
About 300 photos per class: 70% train, 15% validation, 15% test. Add your own field photos so the model is not only trained on clean lab images.
MobileNetV2 at 224 × 224 has about 3.4 M parameters; int8 quantised it is about 3.5 MB and runs in about 100 to 300 ms on a Pi 4.
Report per-class precision = TP / (TP + FP) and recall = TP / (TP + FN), not just overall accuracy, since classes differ in size.
Pin map
| Signal | Pin or connection |
|---|---|
| Camera | CSI connector |
| WS2812 ring DIN | GPIO 18 (PWM) via 330 Ω, 5 V supply |
| Capture button | GPIO 17 (pull-up) |
| Result | Web page served by the Pi over Wi-Fi |
Firmware outline
- Train on a laptop or Colab: MobileNetV2 with ImageNet weights, new 6-class head, augmentation (flip, rotate, brightness).
- Fine-tune the top layers; export to TensorFlow Lite with int8 quantisation.
- On the Pi: on button press, light the ring, capture 224 × 224 centre crop, run the interpreter.
- Show top-3 classes with confidence; below 60% confidence say 'Not sure: retake'.
- Show the remedy text for the top class and save the photo with the result.
Test plan
| Test | Expected result |
|---|---|
| Test split from the dataset | Accuracy and confusion matrix |
| 100 field photos | Accuracy drop compared with the dataset |
| Leaf of another crop | Low confidence, not a wrong disease |
| Speed on the Pi | Under 1 s per photo |
These rows start your results table when you plan the project.
Viva practice
Say your answer out loud first, then check. The first 2 answers are free; Maker opens all 5.
Make it yours
One or two upgrades for a mini project, two to four for a major one.
Datasheets and sources to cite
- Hughes and Salathé, PlantVillage dataset (2015)
- Howard et al., MobileNets (2017)
- ICAR crop protection advisories
About this project
How much does the plant leaf disease detection with a camera and ai project cost?
About ₹9,380 for the parts in the base list: Raspberry Pi 4 Model B (4 GB), Raspberry Pi Camera Module 3, WS2812B ring (16 LEDs), 32 GB microSD card, Raspberry Pi 4 USB-C 15 W supply, Case, button and leaf holder.
How long does it take?
About 14 weeks for the base project, built on a Raspberry Pi 4. Each upgrade adds time.
Which branches is it suitable for?
Computer Science / IT (IoT, AI), Electronics and Communication, as a major project.
Which pins and design calculations does it use?
Camera on CSI connector; WS2812 ring DIN on GPIO 18 (PWM) via 330 Ω, 5 V supply; Capture button on GPIO 17 (pull-up). Worked calculations on this page: dataset split, model size, accuracy measures.
How do I test it?
Test split from the dataset: Accuracy and confusion matrix. 100 field photos: Accuracy drop compared with the dataset. Leaf of another crop: Low confidence, not a wrong disease. Speed on the Pi: Under 1 s per photo.
What are the objectives?
To train an image classifier (transfer learning on MobileNet) for at least five diseases of one crop plus healthy leaves. To run it on the Raspberry Pi in under 1 s per leaf, offline. To show the disease, confidence and a remedy from an agriculture department source. To report accuracy on 100 field photos not used in training.
