Built to order

Crop Disease Detection App using TensorFlow Lite

LeafScan is an Android app that diagnoses crop diseases from a leaf photo using a quantized TensorFlow Lite model running entirely on the phone — no internet needed in the field. The model is a fine-tuned MobileNetV2 trained on the PlantVillage dataset (38 disease classes across 14 crops), converted with post-training quantization for fast on-device inference. Each scan returns the predicted disease with confidence, treatment advice, and a locally stored scan history. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and mobile application development.

Android MobileNetV2GitPlantVillage datasetMaterial Design 3TensorFlow LitePython · TensorFlow/KerasKotlin · Android StudioCameraX · Room/SQLiteSoftware
Crop Disease Detection App using TensorFlow Lite — project thumbnail preview
More project photos (2)

The problem

Farmers lose a large share of yield to plant diseases that are spotted too late, and most AI diagnosis tools need a constant internet connection that simply does not exist in many fields. Existing mobile apps also tend to call a cloud API, which adds cost, latency and privacy concerns for every single scan. This project takes the on-device route: a MobileNetV2 classifier trained on the public PlantVillage leaf dataset is quantized and converted to TensorFlow Lite, then shipped inside a native Android app. A farmer or student photographs a leaf, the model classifies it into one of 38 crop-disease classes in about a tenth of a second, and the app shows the predicted disease, confidence, severity estimate and practical treatment guidance — all without sending anything to a server. Because the whole pipeline (training notebook, quantized model, Android source) is built in the open, the student can explain and defend every stage at the review.

How it works

  1. The training notebook loads PlantVillage (approximately 54,300 single-leaf images, 38 classes), resizes each image to 224×224, normalizes pixel values, and splits the data 80/10/10 into train, validation and test sets.
  2. A MobileNetV2 pretrained on ImageNet is fine-tuned on the leaf data with the top layers unfrozen; augmentation (rotation, flips, brightness shifts) simulates the varied lighting and angles of real field photos.
  3. The trained Keras model is converted to TensorFlow Lite with post-training INT8 quantization, shrinking it to a few megabytes with only a small drop in accuracy.
  4. In the Android app, the camera or gallery image is center-cropped and resized to 224×224 RGB on the phone, matching the training preprocessing exactly.
  5. The TFLite interpreter runs inference in approximately 100 ms and returns a probability distribution over the 38 crop–disease classes; the app displays the top class and its confidence.
  6. The predicted class is mapped to its treatment advisory card, and the scan is saved to the local SQLite history with photo, result, confidence and timestamp.
  7. Evaluation outputs (confusion matrix, per-class precision/recall/F1) are exported from the notebook into the report, documenting exactly which class pairs the model confuses.

Tech stack:

  • Kotlin, Android Studio (native Android app)
  • TensorFlow Lite (on-device inference)
  • MobileNetV2, ImageNet-pretrained, fine-tuned
  • PlantVillage dataset (Hughes & Salathé, 2015)
  • Python, TensorFlow/Keras (training notebook)
  • CameraX, Room/SQLite (capture + local storage)
  • Material Design 3 UI
  • Git

Dataset & model details

  • Dataset: PlantVillage — Hughes, D.P. & Salathé, M. (2015), "An open access repository of images on plant health to enable the development of mobile disease diagnostics" (arXiv:1511.08060). Approximately 54,300 single-leaf RGB images (256×256, photographed against plain backgrounds), CC0 public domain. 38 classes across 14 crops, validated against the official class list — Apple (Apple_scab, Black_rot, Cedar_apple_rust, healthy), Blueberry (healthy), Cherry (Powdery_mildew, healthy), Corn/maize (Gray_leaf_spot, Common_rust, Northern_Leaf_Blight, healthy), Grape (Black_rot, Esca/Black_Measles, Leaf_blight, healthy), Orange (Haunglongbing/Citrus_greening), Peach (Bacterial_spot, healthy), Pepper/bell (Bacterial_spot, healthy), Potato (Early_blight, Late_blight, healthy), Raspberry (healthy), Soybean (healthy), Squash (Powdery_mildew), Strawberry (Leaf_scorch, healthy), Tomato (Bacterial_spot, Early_blight, Late_blight, Leaf_Mold, Septoria_leaf_spot, Spider_mites, Target_Spot, Mosaic_virus, Yellow_Leaf_Curl_Virus, healthy).
  • Task: 38-class image classification. Input = 224×224×3 RGB leaf photo. Output = probability distribution over the 38 crop–disease classes; the app reports the top class, its softmax confidence and an affected-area estimate.
  • Model: MobileNetV2 (approximately 3.4M parameters, ImageNet-pretrained) with a custom 38-way softmax head, fine-tuned on PlantVillage, then converted to TensorFlow Lite with post-training INT8 quantization for on-device execution.
  • Metrics: Held-out accuracy, per-class precision/recall/F1 and confusion matrix; on-device inference latency. Design target: at least 95% accuracy on the held-out PlantVillage test split. Final performance depends on the dataset split, image quality and class balance — no accuracy is claimed as measured until the training run is executed for the order; the report documents the actual achieved figures.
Parameter Value
Model input 224 × 224 × 3 RGB leaf photo
Classes 38 (26 diseases + healthy leaves, 14 crops)
Base architecture MobileNetV2, approximately 3.4M parameters (published)
Quantized model size Approximately 4–6 MB .tflite after INT8 quantization (design target)
Inference latency Approximately 80–150 ms per scan on a mid-range Android phone (expected, device-dependent)
Held-out accuracy At least 95% (design target, not a measured claim)
Minimum Android version Android 8.0 (API 26) (design target)
Train/val/test split 80/10/10 (design target)
Connectivity None required after install — 100% offline
Local storage SQLite, approximately 50–100 MB for 500 stored scans (expected)

Project features

  • [On-device TFLite inference] The quantized MobileNetV2 model ships inside the APK as a .tflite file — a captured leaf photo is classified on the phone itself in about a tenth of a second, with zero network calls.
  • [38-class disease recognition] Covers the full validated PlantVillage class set: 14 crops (apple, blueberry, cherry, corn, grape, orange, peach, bell pepper, potato, raspberry, soybean, squash, strawberry, tomato) and 26 diseases plus healthy leaves.
  • [Confidence and severity readout] Each scan shows the top predicted class with its softmax confidence and an estimated affected-leaf-area percentage computed from a simple lesion-area heuristic.
  • [Treatment advisory cards] Every disease class maps to practical guidance — cultural practices, spray options and watering advice compiled from agricultural extension sources — shown with each result.
  • [Offline scan history] All scans (photo, result, confidence, timestamp) are stored locally in SQLite, browsable in-app and exportable for the report.
  • [Camera and gallery input] Capture a leaf in the field or pick an existing photo; the app center-crops and resizes to the 224×224 model input with a live preview.
  • [Reproducible training pipeline] The Jupyter training notebook (transfer learning, augmentation, evaluation, TFLite conversion and quantization) is included, so the model is explainable rather than a black box.
  • Optional add-ons (quoted separately): multi-language (Hindi/Marathi) treatment advice; GPS-tagged disease heat-map of scanned fields.
  • Future scope (not implemented): lesion segmentation overlay; severity regression trained on annotated masks; iOS build.

What is included

  • Native Android app source (Kotlin) with the bundled quantized .tflite model
  • Training & evaluation Jupyter notebook (transfer learning, augmentation, TFLite conversion)
  • Confusion matrix, per-class precision/recall/F1 and training-curve plots
  • Treatment advisory content for all 38 classes
  • Project report PDF (background, dataset, model design, quantization, methodology, results)
  • PPT presentation for final review
  • Viva Q&A preparation document (CNNs, transfer learning, quantization, dataset bias, on-device ML)

Limitations & prerequisites

  • Trained on PlantVillage's plain-background single-leaf photos — cluttered field backgrounds and multiple leaves in one frame reduce reliability; the app guides the user to frame one leaf.
  • 38 fixed classes: crops or diseases outside PlantVillage (for example, banana, mango, cotton) are not recognized and would need a retrained model.
  • The severity percentage is a simple area heuristic, not a calibrated agronomic measurement.
  • Treatment advice is general extension guidance, not a substitute for a local agronomist's diagnosis.
  • Accuracy on real field photos is expected to be lower than on the held-out PlantVillage split; the report states the measured figures honestly after training.
  • The iOS build and multi-language advice are future scope, not part of this delivery.

Frequently Asked Questions

Which dataset is used and what are the classes?

PlantVillage (Hughes & Salathé, 2015) — approximately 54,300 labeled leaf images across 38 validated classes and 14 crops, including tomato early/late blight, potato blights, corn rust, grape black rot and healthy leaves for every crop. It is the standard public benchmark for this task and is fully documented in the report.

What model actually runs on the phone?

A MobileNetV2 (ImageNet-pretrained, fine-tuned on PlantVillage) converted to TensorFlow Lite with post-training INT8 quantization. MobileNetV2's depthwise-separable convolutions keep it small enough (~a few MB) to run in about a tenth of a second on a mid-range phone, with no server involved.

What accuracy will the app achieve?

The design target is at least 95% on the held-out PlantVillage test split, with per-class metrics and a confusion matrix documented after the training run. No figure is claimed as measured before training, and field photos with cluttered backgrounds will score lower than the benchmark split.

Can new crops or diseases be added later?

Yes. The training notebook is included, so new labeled classes can be added and the model retrained and re-quantized; the app reads its class labels from a bundled labels file, so swapping the .tflite + labels updates the app without code changes.

Does the app work without internet?

Yes — completely. The quantized model is bundled inside the APK, inference runs on the phone's CPU, and scan history is stored in local SQLite. The only download is the app itself at install time.

Is this project suitable for a final-year project?

Yes — for Computer Science, IT and mobile-application programs. It covers dataset handling, CNN transfer learning, model quantization, native Android development and honest evaluation, each a strong viva discussion point.

Components & software requirements
  • Kotlin, Android Studio (native Android app)
  • TensorFlow Lite (on-device inference)
  • MobileNetV2, ImageNet-pretrained, fine-tuned
  • PlantVillage dataset (Hughes & Salathé, 2015)
  • Python, TensorFlow/Keras (training notebook)
  • CameraX, Room/SQLite (capture + local storage)
  • Material Design 3 UI
  • Git

Dataset & model details

  • Dataset: PlantVillage — Hughes, D.P. & Salathé, M. (2015), "An open access repository of images on plant health to enable the development of mobile disease diagnostics" (arXiv:1511.08060). Approximately 54,300 single-leaf RGB images (256×256, photographed against plain backgrounds), CC0 public domain. 38 classes across 14 crops, validated against the official class list — Apple (Apple_scab, Black_rot, Cedar_apple_rust, healthy), Blueberry (healthy), Cherry (Powdery_mildew, healthy), Corn/maize (Gray_leaf_spot, Common_rust, Northern_Leaf_Blight, healthy), Grape (Black_rot, Esca/Black_Measles, Leaf_blight, healthy), Orange (Haunglongbing/Citrus_greening), Peach (Bacterial_spot, healthy), Pepper/bell (Bacterial_spot, healthy), Potato (Early_blight, Late_blight, healthy), Raspberry (healthy), Soybean (healthy), Squash (Powdery_mildew), Strawberry (Leaf_scorch, healthy), Tomato (Bacterial_spot, Early_blight, Late_blight, Leaf_Mold, Septoria_leaf_spot, Spider_mites, Target_Spot, Mosaic_virus, Yellow_Leaf_Curl_Virus, healthy).
  • Task: 38-class image classification. Input = 224×224×3 RGB leaf photo. Output = probability distribution over the 38 crop–disease classes; the app reports the top class, its softmax confidence and an affected-area estimate.
  • Model: MobileNetV2 (approximately 3.4M parameters, ImageNet-pretrained) with a custom 38-way softmax head, fine-tuned on PlantVillage, then converted to TensorFlow Lite with post-training INT8 quantization for on-device execution.
  • Metrics: Held-out accuracy, per-class precision/recall/F1 and confusion matrix; on-device inference latency. Design target: at least 95% accuracy on the held-out PlantVillage test split. Final performance depends on the dataset split, image quality and class balance — no accuracy is claimed as measured until the training run is executed for the order; the report documents the actual achieved figures.
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download free synopsis (PDF)

Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.

Get a quotation