This repository contains a web application designed to detect diseases in potato and tomato plants using Convolutional Neural Networks (CNNs) based on images of plant leaves.
-
Potato Plant Disease Classification Model
- 🧩 183,747 trainable parameters
- 📷 Trained on a dataset of 1,728 images of potato plant leaves (256x256 pixels each)
- 🎯 Accuracy score: ~80% (79.29%) on a test dataset of 320 images
-
Tomato Plant Disease Classification Model
- 🧩 184,202 trainable parameters
- 📷 Trained on a dataset of 9,344 images of tomato plant leaves (256x256 pixels each)
- 🎯 Accuracy score: ~88.24% on a test dataset of 1,216 images
- Python: TensorFlow, NumPy, Pandas, Matplotlib, Flask
- Frontend: HTML, CSS, JavaScript
-
training: Contains Jupyter notebooks for model training
Training.ipynb
: For training the potato plant disease classification modelTraining_tomato.ipynb
: For training the tomato plant disease classification model
To Retrain or Fine-Tune the Model
- Download the dataset from Kaggle PlantVillage Dataset.
- Unzip the dataset and move the
PlantVillage
folder into thetraining
directory. - Delete all folders related to Bell Pepper in the
PlantVillage
folder as they are not used in this project. - Create a new folder named
PlantVillage_tomato
withintraining
and move all tomato plant folders into this folder.
-
app.py: Contains the backend Flask server, which handles user input, applies the trained models, and returns results to the frontend.
-
Models: Saved models after training
1.keras
: First version of the potato plant disease classification model2.keras
: Second version of the potato plant disease classification modeltomato_model_1.keras
: Tomato plant disease classification model
-
templates: HTML files for the frontend of the Flask app
home.html
: Home page structurepotato_classify.html
: Potato disease classification pagetomato_classify.html
: Tomato disease classification page
-
static: Contains assets, CSS, and JavaScript files for the frontend
- assets: Images used in the frontend
home.css
: Stylesheet forhome.html
classify.css
: Stylesheet for bothpotato_classify.html
andtomato_classify.html
classify.js
: JavaScript file for bothpotato_classify.html
andtomato_classify.html
-
requirements.txt: Lists all dependencies required to create the Python virtual environment for the project.
-
Ensure Python is installed on your machine.
-
Clone the project repository or download the zip file.
-
Open the project folder in VS Code or any other IDE.
-
Create a virtual environment using:
python -m venv <name_of_virtual_environment>
-
Activate the virtual environment:
- On Windows:
.\<name_of_virtual_environment>\Scripts\activate
- On macOS/Linux:
source <name_of_virtual_environment>/bin/activate
- On Windows:
-
Install project dependencies:
pip install -r requirements.txt
-
Run
app.py
:python app.py
- You may see TensorFlow warnings and a localhost link (e.g.,
http://127.0.0.1:5000
) in the terminal. - When you see
* Debugger is active!
, copy the localhost link and paste it into your browser.
- You may see TensorFlow warnings and a localhost link (e.g.,
-
You will be redirected to the web app's home page.
- On the home page, select the model for the plant you want to check.
- Upload an image of the plant leaf.
- Click the "Predict" button.
- The condition of the plant along with the confidence score will appear on the screen.