Potato Life is an automated project for farmers for timely and accurate diagnosis of diseases in potato leaves.
PlantVillage_Data
: Dataset info and zipped images.Training.ipynb
: Data processing and training code.saved_models/
: Contains trained model versions.api/
: Contains server.py for FastAPI and requirements.txt.app.py
: Streamlit web app code.requirements.txt
: Required libraries for deployment.runtime.txt
: Specifies Python runtime version for deployment.
- 🌐 Web App Link: Potato Health Checker
- 📂 Source Dataset (Kaggle): Plant Village
- 📄 Published Dataset (Kaggle): Potato Leaf Disease Gallery
- 📓 Kaggle Notebook: Potato Disease Classification
- Potato(Solanum tuberosum) is the fourth-most important staple crop in the world.
- Potato crops are susceptible to multiple diseases.
- This project identifies and classifies major potato diseases.
- By accurately diagnosing diseases, farmers can apply targeted treatments, reducing the need for excessive pesticide use.
- Potato crops are highly vulnerable to diseases, impacting yield and food security.
- Early, precise disease detection is crucial for efficient management and reduced crop loss.
- Traditional diagnosis methods are slow and unsuitable for large-scale agriculture.
- There's a need for automated, scalable solutions for disease detection.
- We have used publicly available ‘PlantVillage’ dataset.
- It includes 1000 images each of ‘Early Blight’ and ‘Late Blight’, along with 152 ‘Healthy’ leaf images, totalling 2152 potato leaf images.
- Data Batch Loading: Into 68 batches of 32 images each
- Data Partitioning: Into train, test and validation sub-datasets
- Data Resizing: To a constant size of 256 X 256
- Data Rescaling: Divided pixel intensities of each image by 255.
- Data Augmentation: As random flipping and random rotation
- CNN Model Architecture: Consisted of-
- 6 convolutional layers with 3X3 kernel size and ReLU activation function
- 6 max-pooling layers
- A dropout layer
- A flattening layer
- 2 dense layers
- Compiled the model using Adam optimizer, Sparse categorical cross-entropy loss and Accuracy metric.
- The training process involved 50 epochs, with each epoch comprising 54 steps.
-
Implementation details:
- Endpoint Creation: We developed a FastAPI server on localhost, listening on port 8000.
- Endpoint Routes: We implemented the Post / Predict API route to facilitate interaction with the model. This route accepts an uploaded potato leaf image, processes it, feeds it into our trained model, and returns the predicted class (early blight, late blight, or healthy) along with a confidence score.
-
Image Processing and Model Prediction Upon receiving an image upload through the /predict endpoint, FastAPI performs the following steps:
- Image Conversion: FastAPI converts the uploaded image into a NumPy array.
- Tensor Conversion: The NumPy array is further transformed into a tensor, which is compatible with our trained model.
- Model Prediction: The tensorized image is passed through the model, and the model predicts the disease class and provides a confidence score for the prediction.
-
Response Format
- Developed an interactive web app using Streamlit.
- Key Features:
- Image upload functionality with format validation.
- Model prediction and visualization of class and confidence.
- User-friendly layout with sidebar instructions.
- Deployed on Streamlit Community Cloud for global access.
- Enables seamless interaction for farmers and researchers for real-time disease detection.
-
Upon completion of training, our model achieved a remarkable test accuracy of 98.83%, demonstrating the model's efficacy in classifying potato leaves into three categories: early blight, late blight, and healthy conditions.
-
Alongside, we have the model’s predictions on a sample of test images, where:
-
Postman software interacting with the model via API request and giving prediction result as a json response for a sample leaf image.
To set up the project on your local machine, follow these steps:
- Clone the repository:
git clone https://github.com/krishnaura45/PotatoLife.git
cd PotatoLife
- Install dependencies:
pip install -r requirements.txt
- Run the Streamlit app:
streamlit run app.py
- Fork the repository.
- Create a new branch.
- Commit changes with clear messages.
- Submit a pull request.
- Ensure new features are tested and documented.
- Python: Backend logic and data handling.
- TensorFlow: Deep learning model.
- Streamlit: Web app development.
- FastAPI: API interaction and server handling.
- Postman: API testing and interaction.
- Pillow, NumPy, Matplotlib: Image processing and visualization.
- Create a mobile app
- Emphasize on the need for FastAPI server security, including integration with Docker and measures like authentication and authorization to safeguard model and user data.
- S. Biswas, B. Jagyasi, B. P. Singh and M. Lal, "Severity identification of Potato Late Blight disease from crop images captured under uncontrolled environment," 2014 IEEE Canada International Humanitarian Technology Conference - (IHTC), Montreal, QC, Canada, 2014, pp. 1-5, doi: 10.1109/IHTC.2014.7147519.
- G. Athanikar and P. Badar, “Potato Leaf Diseases Detection and Classification System”, IJCSMC, Vol. 5, Issue. 2, February 2016, pg.76 – 88
- Rabbia Mahum, Haris Munir, Zaib-Un-Nisa Mughal, Muhammad Awais, Falak Sher Khan, Muhammad Saqlain, Saipunidzam Mahamad & Iskander Tlili. A novel framework for potato leaf disease detection using an efficient deep learning model, Human and Ecological Risk Assessment: An International Journal; 2022.
- Chakraborty KK, Mukherjee R, Chakroborty C, Bora K. Automated recognition of optical image based potato leaf blight diseases using deep learning. Physiological and Molecular Plant Pathology. 2022;117:101781
- Krishna Dubey (Data Collection / Machine Learning / API Development / Web App Development)
- Pankaj Kumar Giri (API Code Help)