--- license: gpl-3.0 --- # Potato and Tomato Disease Classification Web Application ### Overview This project is a web application developed using Flask that allows users to upload images of potato or tomato leaves and receive predictions regarding potential diseases. The application utilizes two deep learning models: one trained to classify potato leaf diseases and another for tomato leaf diseases. Both models were trained using convolutional neural networks (CNNs) and implemented using PyTorch. ### Key Features - **Image Upload:** Users can upload images of potato or tomato leaves. - **Disease Prediction:** The application predicts whether the leaf is healthy or affected by specific diseases. - **Dynamic Background:** The background image of the web page dynamically changes based on whether the user selects potato or tomato. - **Probability Display:** The probability of the predicted class is displayed as a percentage. ### Technologies Used - **Python:** Core programming language used for model development and Flask backend. - **Flask:** Web framework for developing the web application. - **PyTorch:** Deep learning framework used to develop and train the models. - **HTML/CSS:** For creating the frontend of the web application. - **PIL (Pillow):** For image processing. - **OpenCV:** For image display and preprocessing. - **Torchvision:** For image transformation utilities. ### Models - **Potato Disease Classification Model** - **Classes:** Potato Early Blight Potato Late Blight Potato Healthy - **Techniques Used:** Convolutional layers for feature extraction. Batch normalization and max pooling for enhanced training stability and performance. Dropout layers to prevent overfitting. - **Tomato Disease Classification Model** - **Classes:** Tomato Early Blight Tomato Late Blight Tomato Healthy - **Techniques Used:** Similar architecture to the potato model with appropriate adjustments for tomato disease classification. Batch normalization, max pooling, and dropout layers are also used here. ### Web Application - **Backend** The backend of the application is powered by Flask. It loads the trained models, handles image uploads, processes images, and returns predictions to the frontend. - **Model Loading:** Both models (potato and tomato) are loaded at the start of the application to minimize latency during prediction. - **Prediction Logic:** Depending on the selected plant type (potato or tomato), the corresponding model is used to predict the disease class. - **Dynamic Background:** The background image on the frontend changes based on the selected plant type, enhancing user experience. - **Frontend** The frontend is developed using HTML and CSS, with Bootstrap for responsive design. - **File Upload Interface:** Users can upload an image of a leaf. - **Prediction Display:** After processing, the application displays the predicted disease class and the associated probability. - **Dynamic Background:** The background image changes depending on whether the user is predicting for potato or tomato. ### Usage 1. Install the required dependencies using ```pip install -r requirements.txt```. 2. Download the pre-trained model weights and place them in the `models/` directory. 3. Run the Flask web application using ```python app.py```. 4. Access the application in your web browser at `http://localhost:5000`. ### Outcome - **Performance** - **Potato Model:** Achieved an accuracy of 98% on the validation set, with strong performance in classifying Early Blight, Late Blight, and Healthy leaves. - **Tomato Model:** Achieved an accuracy of 97% on the validation set, effectively distinguishing between Early Blight, Late Blight, and Healthy leaves. - **Benefits** - **Disease Detection:** Helps farmers and agriculturists detect diseases in potato and tomato plants early, potentially preventing crop losses. - **User-Friendly Interface:** The web application provides a simple interface for non-technical users to diagnose plant diseases.