Skip to content

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯” Potato Disease Classification

A Deep Learning-based Potato Disease Classification project that classifies potato leaf images into Early Blight, Late Blight, and Healthy categories.

The project covers the complete workflow from dataset preparation and CNN model development to model conversion, Android deployment, emulator testing, APK generation, and APK analysis.

The trained model was converted into TensorFlow Lite (.tflite) format and integrated into an Android application using Android Studio, Java, and Gradle. The resulting APK was also analyzed using JADX for educational purposes.


πŸ“Œ Project Overview

Potato plants can be affected by diseases such as Early Blight and Late Blight, which can negatively impact crop health and yield. This project explores the use of Computer Vision and Deep Learning to automatically identify the condition of potato leaves from images.

The project follows an end-to-end workflow:

Potato Leaf Dataset
        ↓
Data Preparation
        ↓
CNN Model Development
        ↓
Model Training
        ↓
Model Evaluation
        ↓
Model Export / Conversion
        ↓
TensorFlow Lite Model
        ↓
Android Integration
        ↓
Android Testing
        ↓
APK Generation
        ↓
JADX APK Analysis

The project therefore combines Deep Learning, Model Deployment, Android Development, and APK Analysis into a single workflow.


🎯 Objective

The primary objectives of this project are:

  • Build an image classification model for potato leaf diseases.
  • Classify potato leaves into three categories.
  • Train and evaluate a CNN-based deep learning model.
  • Save the trained model in deployable formats.
  • Convert the model into TensorFlow Lite format.
  • Integrate the .tflite model into an Android application.
  • Implement image-based prediction functionality on Android.
  • Handle required Android permissions.
  • Display the prediction results to the user.
  • Test the complete application using an Android emulator.
  • Generate an Android APK.
  • Analyze the generated APK using JADX.

🌿 Disease Classes

The dataset used in the project contains three potato leaf categories:

Class Description
Potato___Early_blight Potato leaves affected by Early Blight
Potato___Late_blight Potato leaves affected by Late Blight
Potato___healthy Healthy potato leaves

The corresponding images are organized inside the Potato Plant Disease directory.


πŸ“‚ Repository Structure

Potato_Disease_Classification/
β”‚
β”œβ”€β”€ AModel/
β”‚   β”‚
β”‚   β”œβ”€β”€ 1/
β”‚   β”‚   β”œβ”€β”€ variables/
β”‚   β”‚   β”œβ”€β”€ fingerprint.pb
β”‚   β”‚   β”œβ”€β”€ keras_metadata.pb
β”‚   β”‚   β”œβ”€β”€ model.tflite
β”‚   β”‚   └── saved_model.pb
β”‚   β”‚
β”‚   β”œβ”€β”€ 1.h5
β”‚   └── 1.keras
β”‚
β”œβ”€β”€ Potato Disease Jupyter/
β”‚   β”œβ”€β”€ .ipynb_checkpoints/
β”‚   └── Potato Disease Classification.ipynb
β”‚
β”œβ”€β”€ Potato Plant Disease/
β”‚   β”œβ”€β”€ Potato___Early_blight/
β”‚   β”œβ”€β”€ Potato___Late_blight/
β”‚   └── Potato___healthy/
β”‚
β”œβ”€β”€ app-debug.apk
β”‚
└── app-debug.apk.jadx

πŸ“ Repository Components

Potato Plant Disease/

This directory contains the potato leaf image dataset organized according to the classification labels.

Potato Plant Disease/
β”‚
β”œβ”€β”€ Potato___Early_blight/
β”œβ”€β”€ Potato___Late_blight/
└── Potato___healthy/

Each directory contains images belonging to its respective class.

This organization allows the images to be associated with their corresponding labels during the model development process.


Potato Disease Jupyter/

This directory contains the Jupyter Notebook used for the deep learning portion of the project:

Potato Disease Classification.ipynb

The notebook contains the model-development workflow, including the preparation of the image dataset, deep learning model development, training, evaluation, and model conversion/export activities.


🧠 Deep Learning

The classification model was developed using a Convolutional Neural Network (CNN).

CNNs are well suited for image classification because they can learn spatial patterns and visual features directly from images.

The model-development workflow includes:

Images
  ↓
Preprocessing
  ↓
CNN
  ↓
Feature Extraction
  ↓
Classification
  ↓
Predicted Class

The model learns visual characteristics from potato leaf images and uses them to distinguish between:

  • Early Blight
  • Late Blight
  • Healthy

Technologies

  • Python
  • TensorFlow
  • Keras
  • Jupyter Notebook
  • CNN

πŸ’Ύ Model Artifacts

The AModel directory contains the generated model files and TensorFlow artifacts.

AModel/
β”‚
β”œβ”€β”€ 1.keras
β”œβ”€β”€ 1.h5
β”‚
└── 1/
    β”œβ”€β”€ variables/
    β”œβ”€β”€ fingerprint.pb
    β”œβ”€β”€ keras_metadata.pb
    β”œβ”€β”€ model.tflite
    └── saved_model.pb

Keras Model

AModel/1.keras

The .keras file represents the model saved in the Keras format.

H5 Model

AModel/1.h5

The .h5 file represents another serialized version of the trained model using the HDF5-based Keras format.

SavedModel

The 1/ directory contains TensorFlow SavedModel-related artifacts, including:

saved_model.pb
variables/
fingerprint.pb
keras_metadata.pb

TensorFlow Lite

The most important model artifact for the Android application is:

AModel/1/model.tflite

This model was used for performing inference inside the Android application.


πŸ“± Android Application

The trained TensorFlow Lite model was integrated into an Android application using:

  • Android Studio
  • Java
  • Gradle
  • TensorFlow Lite

A ready-made Android template obtained from a YouTube tutorial was used as the initial project/UI foundation.

The template was then modified and adapted extensively to implement the requirements of this project and integrate the trained deep learning model.

The Android application is therefore not simply the original template with a model file added; the application was modified to implement the project's required functionality.


βš™οΈ Android Implementation

The Android application uses the TensorFlow Lite model:

model.tflite

to perform predictions on potato leaf images.

The implemented application functionality includes:

πŸ” Permission Handling

The application handles the Android permissions required for its image/input-related functionality.

This allows the application to interact with the required device resources appropriately.


πŸ–ΌοΈ Image Input

The application allows an image of a potato leaf to be provided as input.

The input image is prepared in a format suitable for the TensorFlow Lite model.


🧠 TensorFlow Lite Inference

The .tflite model is loaded by the Android application and used to perform inference.

The general prediction pipeline is:

Input Image
     ↓
Image Processing
     ↓
TensorFlow Lite Model
     ↓
Model Inference
     ↓
Output Probabilities / Prediction
     ↓
Predicted Disease

πŸ“Š Prediction Handling

The Android application processes the output generated by the TensorFlow Lite model to determine the predicted class.

The prediction is then presented to the user through the application's interface.


πŸ“± Result Presentation

After inference, the application displays the resulting classification to the user.

This connects the deep learning model's output with the Android application's user-facing functionality.


πŸ§ͺ Android Testing

The Android application was tested directly inside Android Studio using the:

Google Pixel 5a Emulator

Testing the application in the emulator helped verify the complete prediction workflow, including:

  • Application launch
  • UI interaction
  • Permission handling
  • Image input
  • Image processing
  • TensorFlow Lite model loading
  • Model inference
  • Prediction handling
  • Result display
  • Overall application behavior

The emulator provided a controlled Android environment for testing the deployed deep learning model without requiring a physical Android device.


πŸ“¦ APK Generation

After implementing and testing the Android application, the project was built using Android Studio and Gradle.

The generated APK is included in the repository:

app-debug.apk

The APK contains the Android application with the integrated TensorFlow Lite model and implemented prediction workflow.


πŸ” APK Reverse Engineering with JADX

After generating the APK, JADX was used to decompile and inspect the application.

The resulting JADX output is included in:

app-debug.apk.jadx

This provides an opportunity to inspect how the compiled Android application is represented after being packaged into an APK.

The analysis can be used to explore:

  • Decompiled Java classes
  • Android application components
  • Application structure
  • Permission-related implementation
  • TensorFlow Lite integration
  • Prediction-related logic
  • Resources
  • Manifest information
  • Compiled application behavior

⚠️ About the JADX Output

JADX reconstructs readable Java/source-like code from compiled Android applications.

Therefore, the decompiled output should not be considered an exact representation of the original source code.

Differences can occur because of:

  • Compilation
  • Optimization
  • Resource processing
  • Code transformation
  • Obfuscation
  • Other Android build processes

The JADX output in this repository is included for educational and application-analysis purposes.


πŸ”„ Complete Project Workflow

The complete project can be summarized as follows:

1. Dataset

Potato leaf images are organized into:

Early Blight
Late Blight
Healthy

2. Data Preparation

The images are prepared for use in the deep learning model.

3. CNN Development

A CNN-based image classification model is developed using TensorFlow/Keras.

4. Model Training

The model is trained using the potato leaf dataset.

5. Model Evaluation

The trained model is evaluated to understand its classification performance.

6. Model Export

The trained model is saved into formats such as:

.keras
.h5
SavedModel

7. TensorFlow Lite Conversion

The model is converted into:

model.tflite

for mobile deployment.

8. Android Integration

The TensorFlow Lite model is integrated into an Android application using:

Android Studio
Java
Gradle
TensorFlow Lite

9. Application Development

The initial Android template is modified to implement:

Permissions
     ↓
Image Input
     ↓
Image Processing
     ↓
TFLite Inference
     ↓
Prediction Processing
     ↓
Result Display

10. Emulator Testing

The application is tested using the Google Pixel 5a emulator in Android Studio.

11. APK Generation

The Android application is packaged as:

app-debug.apk

12. APK Analysis

The generated APK is analyzed using JADX, with the output included as:

app-debug.apk.jadx

πŸ› οΈ Technologies Used

Category Technologies
Programming Python, Java
Deep Learning TensorFlow, Keras, CNN
Dataset Processing Python
Development Jupyter Notebook
Model Formats .keras, .h5, SavedModel, .tflite
Android Development Android Studio
Android Programming Java
Build System Gradle
Mobile DL TensorFlow Lite
Android Testing Google Pixel 5a Emulator
APK Analysis JADX
Version Control Git, GitHub

πŸŽ“ Learning Outcomes

This project provided practical experience across multiple stages of an DL application lifecycle.

Deep Learning

  • Image classification
  • CNN-based model development
  • Dataset organization
  • Image preprocessing
  • Model training
  • Model evaluation
  • Model serialization

Model Deployment

  • Keras model handling
  • H5 model handling
  • TensorFlow SavedModel
  • TensorFlow Lite conversion
  • Mobile model deployment

Android Development

  • Android Studio
  • Java
  • Gradle
  • Android permission handling
  • Image input handling
  • TensorFlow Lite inference
  • Prediction processing
  • Result presentation
  • Emulator-based testing

APK Analysis

  • APK generation
  • APK decompilation
  • JADX
  • Decompiled Java inspection
  • Understanding compiled Android application structure

πŸ“ˆ End-to-End Architecture

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚   Potato Leaf Images β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚ Data Preparation &   β”‚
                 β”‚    Preprocessing     β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚     CNN Model        β”‚
                 β”‚ TensorFlow / Keras   β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚ Training & Evaluationβ”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚   Trained Model      β”‚
                 β”‚ .keras / .h5         β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚ TensorFlow Lite      β”‚
                 β”‚    Conversion        β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚    model.tflite      β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚        Android Application       β”‚
          β”‚                                  β”‚
          β”‚ Java + Gradle + Android Studio   β”‚
          β”‚                                  β”‚
          β”‚ Permissions β†’ Image β†’ Inference  β”‚
          β”‚              β†’ Prediction        β”‚
          β”‚              β†’ Result            β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚ Google Pixel 5a      β”‚
                 β”‚ Android Emulator     β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚     app-debug.apk    β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            ↓
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚       JADX           β”‚
                 β”‚   APK Analysis       β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ‘¨β€πŸ’» Project Summary

Potato Disease Classification demonstrates an end-to-end deep learning deployment workflow:

Deep Learning
      ↓
CNN Classification
      ↓
TensorFlow / Keras
      ↓
TensorFlow Lite
      ↓
Android + Java + Gradle
      ↓
Emulator Testing
      ↓
APK Generation
      ↓
JADX Analysis

The project demonstrates how a deep learning model can move beyond experimentation in a Jupyter Notebook and be integrated into a functional mobile application capable of performing on-device predictions.


πŸ‘¨β€πŸ’» Author

Sahil Salunke


🌐 Project Repository

GitHub: Potato Disease Classification


About

CNN-based potato leaf disease classification using TensorFlow/Keras, TensorFlow Lite, and Android Studio. Includes model artifacts, dataset, mobile deployment, emulator testing, APK, and JADX analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages