File size: 4,059 Bytes
1cc51d9
 
 
5a02685
 
1cc51d9
5a02685
1cc51d9
 
5a02685
 
e1706f7
 
 
 
5a02685
5d21da5
5a02685
e1706f7
 
 
 
 
 
 
5a02685
5d21da5
5a02685
 
 
1cc51d9
 
 
5a02685
1cc51d9
 
 
 
5a02685
 
f974645
 
 
5a02685
f974645
 
1cc51d9
5a02685
 
e1706f7
1cc51d9
 
e053ae7
 
 
1cc51d9
e1706f7
1cc51d9
 
e053ae7
 
 
1cc51d9
5a02685
276643c
 
 
 
 
 
5a02685
e1706f7
5a02685
 
e1706f7
e053ae7
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
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.