7jimmy commited on
Commit
855a045
·
verified ·
1 Parent(s): ec883d5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -129
README.md CHANGED
@@ -1,129 +1,31 @@
1
- # Cotton-Plant-Disease-Detection
2
- A deep learning project for cotton plant disease detection using tensorflow
3
-
4
- It mainly focus on the diseases which occur only on leaves. However, more research is done on diseases that occur on stem, flowers, buds and boll.
5
-
6
- The diseases identified by this model are:
7
-
8
- . Diseases caused by aphids,
9
-
10
- . Diseases caused by army worms,
11
-
12
- . Bacterial Blight,
13
-
14
- . Powdery Mildew and
15
-
16
- . Target sport.
17
-
18
- The data used in this project contains images of all the 5 types of diseases listed above including those of healthy leaves for comparison with the diseased ones.
19
-
20
- Below is an example of a healthy cotton plant's leaf:
21
-
22
- ![sample-healthy-leaf](https://user-images.githubusercontent.com/78556152/210360017-06e7a605-2214-4074-9584-160850d47bcd.png)
23
-
24
-
25
- ## Defining some parameters for the loader
26
-
27
- Batch size is set to 32
28
-
29
- image height set to 180 and
30
-
31
- image width set to 180
32
-
33
- ## Splitting the Dataset into Training and Validation
34
-
35
- The data is split into training and validation
36
-
37
- Training set is given 80% of the data and
38
-
39
- Validation set is given 20% of the data
40
-
41
- ## Classes
42
-
43
- The dataset is classified into six classes based on the plant's images of different diseases and the healthy ones.
44
-
45
- This classes include; Aphids, Army Worms, Bacterail Blight, Healthy leaf, Powdery Mildew and Target Spot.
46
-
47
- The image below shows the classes of the dataset:
48
-
49
- ![Screenshot 2023-01-03 155358](https://user-images.githubusercontent.com/78556152/210361283-94b2de53-76cf-4787-9a65-75ea18eee1f7.png)
50
-
51
-
52
- Below are some images from the training dataset
53
-
54
- ![sample_training_diseases_images](https://user-images.githubusercontent.com/78556152/210361611-af3d4977-5c15-4e4f-b591-4f690e390244.png)
55
-
56
-
57
- ## Keras Model
58
-
59
- The dataset is configured for performance with two functions
60
-
61
- data.cache() and
62
-
63
- data.prefetch()
64
-
65
- The RGB channel values are standardized to [0,1] range by the use of tf.keras.Rescalling
66
-
67
- A Keras model is created and compiled. Below is the summary of the model
68
-
69
- ![Screenshot 2023-01-03 160123](https://user-images.githubusercontent.com/78556152/210362238-563e08ef-4545-4875-9a9f-444dacb6e0ce.png)
70
-
71
- ## Training the Model
72
-
73
- The model is then trained for 10 epochs as shown below
74
-
75
- ![Screenshot 2023-01-03 161615](https://user-images.githubusercontent.com/78556152/210364558-340c558f-74d9-4082-9a4d-dd564fa465a6.png)
76
-
77
-
78
- The results are not remarkable with validation accuracy being only 0.6170 despite training accuracy being 0.9895
79
-
80
- ## Visualize Training Results
81
-
82
- Plots on accuracy and loss for training and validation sets are created and below are the results
83
-
84
- ![training_and_validation_accuracy_and_loss_1](https://user-images.githubusercontent.com/78556152/210365383-57cdef02-3f4a-4e15-ae72-639fc8a1bcea.png)
85
-
86
- From visualizing the training results above, the training accuracy is high but the validation accuracy is very low. The same applies to loss; the training loss is lower than the validation loss.
87
-
88
- This shows that the model did not fit well causing a problem of overfitting that resulted into huge margins between training and validation results.
89
-
90
- Some measures are taken to solve the overfitting problem below.
91
-
92
- ## Solving the problem of Overfitting
93
-
94
- Two methods are used to solve overfitting:
95
-
96
- 1. Data Augmentation- this creates modified copies of the dataset using existing data to artificially increase the training set.
97
- 2. Dropout - This is a layer that randomly sets input units to 0 with a frequency of rate at each step during training time, which helps prevent overfitting.
98
-
99
- Below is an example of augmented images:
100
-
101
- ![sample_augmented_images](https://user-images.githubusercontent.com/78556152/210369044-61e52e36-b7f1-4b65-aa41-325d998cc47a.png)
102
-
103
- The code snippet below shows a new model with a dropout layer
104
-
105
- ![Screenshot 2023-01-03 164714](https://user-images.githubusercontent.com/78556152/210369702-e78e45e3-4631-4d37-90db-e6c027b56293.png)
106
-
107
- ## Training the New Model and Visualizing the Training Results
108
-
109
- The new model trains with remarkable results. The training accuracy is 80% and the validation accuracy is 70%.
110
-
111
- Plotting a graph of Accuracy and loss, the training and validation results are closer to each other indicating that the model fit well as shown in the image below.
112
-
113
- ![training_and_validation_accuracy_and_loss_2](https://user-images.githubusercontent.com/78556152/210370737-6f5a82f5-940e-4967-bce5-50fe9d4780c5.png)
114
-
115
- ## Predicting on New Data
116
-
117
- A new image is given to the model for prediction, the model predicts the image's class with a high degree of accuracy and confidence.
118
-
119
- ![Screenshot 2023-01-03 165756](https://user-images.githubusercontent.com/78556152/210371600-4312f7ec-f235-4b6e-8a2e-6e9bd4ee9fcc.png)
120
-
121
- ## Saving the Model and Serving it with tensorflow serving
122
-
123
- The model is saved and served with tensorflow serving in docker during production.
124
-
125
- ![Screenshot 2023-01-03 170143](https://user-images.githubusercontent.com/78556152/210372276-feb6398c-df68-4d29-b5bc-2ac565c5db47.png)
126
-
127
- ## Conclusion
128
-
129
- There are a lot of crop diseases that affect different crops. In this project I focused on those that affect cotton plant specifically on the leaves. This model has done a good job of training and classifying images of five diseases that affect leaves of a cotton plant after which it can then detect a disease if new data is given to it based on those five classes of diseases. I can conclude that it is very possible to train a deep learning model to detect different types of crop diseases when given enough data to train on.
 
1
+ ---
2
+ title: Cotton Plant Disease Classifier
3
+ sdk: streamlit
4
+ emoji: 🏃
5
+ colorFrom: green
6
+ colorTo: yellow
7
+ pinned: true
8
+ short_description: This Streamlit app utilizes a deep learning model to classif
9
+ ---
10
+
11
+ This Streamlit app utilizes a deep learning model to classify images of cotton leaves into various disease categories or as healthy. The model, built with TensorFlow, has been trained on a dataset of cotton plant leaves under different conditions, aiming to assist farmers and agronomists in early disease detection and management.
12
+
13
+ ## Features
14
+ - **Image Upload**: Users can upload images of cotton leaves to get instant predictions.
15
+ - **Disease Classification**: The app classifies the leaf as healthy or identifies the specific disease affecting it.
16
+ - **Model Insights**: Provides insights into the confidence levels of the predictions.
17
+
18
+ ## How to Use
19
+ 1. **Upload Image**: Click on the 'Upload Image' button to upload a photo of a cotton leaf.
20
+ 2. **View Prediction**: After the image is processed, view the prediction displayed on the screen.
21
+
22
+ ## Technology Stack
23
+ - **TensorFlow & Keras**: For building and training the deep learning model.
24
+ - **Streamlit**: For creating the web application interface.
25
+ - **Python**: The backend logic and model training scripts.
26
+
27
+ ## Configuration Reference
28
+ For more details on configuring and deploying Streamlit apps on Hugging Face Spaces, check out the [configuration reference](https://huggingface.co/docs/hub/spaces-config-reference).
29
+
30
+ ## About
31
+ Developed by Sharjeel Ahmad khan, this tool aims to leverage machine learning for agricultural advancements, making it easier to detect and manage plant diseases early on.