Spaces:
No application file
No application file
Upload 259 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +9 -0
- .ipynb_checkpoints/Cotton Plant Disease Detection-checkpoint.ipynb +6 -0
- Cotton Plant Disease Detectio.ipynb +0 -0
- Cotton Plant Disease Detection.py +0 -0
- ML/models.config +26 -0
- ML/models/cotton_plant_disease_model/1/fingerprint.pb +3 -0
- ML/models/cotton_plant_disease_model/1/keras_metadata.pb +3 -0
- ML/models/cotton_plant_disease_model/1/saved_model.pb +3 -0
- ML/models/cotton_plant_disease_model/1/variables/variables.data-00000-of-00001 +3 -0
- ML/models/cotton_plant_disease_model/1/variables/variables.index +0 -0
- README.md +129 -13
- cotton-plant-disease-data/Aphids/1.jpg +3 -0
- cotton-plant-disease-data/Aphids/10.jpg +0 -0
- cotton-plant-disease-data/Aphids/11.jpg +0 -0
- cotton-plant-disease-data/Aphids/13.jpg +0 -0
- cotton-plant-disease-data/Aphids/14.jpg +0 -0
- cotton-plant-disease-data/Aphids/15.jpg +0 -0
- cotton-plant-disease-data/Aphids/16.jpg +0 -0
- cotton-plant-disease-data/Aphids/17.jpg +0 -0
- cotton-plant-disease-data/Aphids/18.jpg +0 -0
- cotton-plant-disease-data/Aphids/19.jpg +3 -0
- cotton-plant-disease-data/Aphids/2.jpg +0 -0
- cotton-plant-disease-data/Aphids/20.jpg +0 -0
- cotton-plant-disease-data/Aphids/21.jpg +0 -0
- cotton-plant-disease-data/Aphids/22.jpg +0 -0
- cotton-plant-disease-data/Aphids/23.jpg +0 -0
- cotton-plant-disease-data/Aphids/24.jpg +0 -0
- cotton-plant-disease-data/Aphids/25.jpg +0 -0
- cotton-plant-disease-data/Aphids/26.jpg +0 -0
- cotton-plant-disease-data/Aphids/27.jpg +0 -0
- cotton-plant-disease-data/Aphids/28.jpg +0 -0
- cotton-plant-disease-data/Aphids/29.jpg +0 -0
- cotton-plant-disease-data/Aphids/3.jpg +0 -0
- cotton-plant-disease-data/Aphids/30.jpg +0 -0
- cotton-plant-disease-data/Aphids/31.jpg +0 -0
- cotton-plant-disease-data/Aphids/32.jpg +0 -0
- cotton-plant-disease-data/Aphids/33.jpg +0 -0
- cotton-plant-disease-data/Aphids/34.jpg +0 -0
- cotton-plant-disease-data/Aphids/35.jpg +3 -0
- cotton-plant-disease-data/Aphids/36.jpg +0 -0
- cotton-plant-disease-data/Aphids/37.jpg +0 -0
- cotton-plant-disease-data/Aphids/38.jpg +0 -0
- cotton-plant-disease-data/Aphids/39.jpg +0 -0
- cotton-plant-disease-data/Aphids/4.jpg +0 -0
- cotton-plant-disease-data/Aphids/40.jpg +0 -0
- cotton-plant-disease-data/Aphids/5.jpg +0 -0
- cotton-plant-disease-data/Aphids/6.jpg +0 -0
- cotton-plant-disease-data/Aphids/7.jpg +0 -0
- cotton-plant-disease-data/Aphids/8.jpg +0 -0
- cotton-plant-disease-data/Aphids/9.jpg +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
cotton-plant-disease-data/Aphids/1.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
cotton-plant-disease-data/Aphids/19.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
cotton-plant-disease-data/Aphids/35.jpg filter=lfs diff=lfs merge=lfs -text
|
39 |
+
cotton-plant-disease-data/Bacterial[[:space:]]Blight/34.jpg filter=lfs diff=lfs merge=lfs -text
|
40 |
+
cotton-plant-disease-data/Target[[:space:]]spot/36.jpg filter=lfs diff=lfs merge=lfs -text
|
41 |
+
images/end_to_end_project/sample_augmented_images.png filter=lfs diff=lfs merge=lfs -text
|
42 |
+
images/end_to_end_project/sample_training_diseases_images.png filter=lfs diff=lfs merge=lfs -text
|
43 |
+
images/end_to_end_project/sample-healthy-leaf.png filter=lfs diff=lfs merge=lfs -text
|
44 |
+
ML/models/cotton_plant_disease_model/1/variables/variables.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
|
.ipynb_checkpoints/Cotton Plant Disease Detection-checkpoint.ipynb
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [],
|
3 |
+
"metadata": {},
|
4 |
+
"nbformat": 4,
|
5 |
+
"nbformat_minor": 5
|
6 |
+
}
|
Cotton Plant Disease Detectio.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
Cotton Plant Disease Detection.py
ADDED
File without changes
|
ML/models.config
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
model_config_list {
|
2 |
+
config {
|
3 |
+
name: 'saved_model'
|
4 |
+
base_path: '/models/cotton_plant_disease_model/'
|
5 |
+
model_platform: 'tensorflow'
|
6 |
+
|
7 |
+
model_version_policy {
|
8 |
+
|
9 |
+
specific {
|
10 |
+
version: 1
|
11 |
+
version: 2
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
version_labels {
|
16 |
+
key: 'stable'
|
17 |
+
value: 1
|
18 |
+
}
|
19 |
+
|
20 |
+
version_labels {
|
21 |
+
key: 'canary'
|
22 |
+
value: 2
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
ML/models/cotton_plant_disease_model/1/fingerprint.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:43fcf333e5c236b928551fe7701a02da128516cdb88c7a2e7959a3ae182779c5
|
3 |
+
size 56
|
ML/models/cotton_plant_disease_model/1/keras_metadata.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:393e43589523b2a14c146a9033d56c78b2b86b58619f1160baa80dc3e9365e28
|
3 |
+
size 28649
|
ML/models/cotton_plant_disease_model/1/saved_model.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6a5f8cff62d6b27c99a13dcb24e29d16d1c8f8b5e8b5971b8434c935b1323c8f
|
3 |
+
size 1686883
|
ML/models/cotton_plant_disease_model/1/variables/variables.data-00000-of-00001
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c265d850a30c73f529ae0ed8aaf7b8f430c465457562875f8c9f5f41b54a9e51
|
3 |
+
size 47887585
|
ML/models/cotton_plant_disease_model/1/variables/variables.index
ADDED
Binary file (2.7 kB). View file
|
|
README.md
CHANGED
@@ -1,13 +1,129 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
cotton-plant-disease-data/Aphids/1.jpg
ADDED
![]() |
Git LFS Details
|
cotton-plant-disease-data/Aphids/10.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/11.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/13.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/14.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/15.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/16.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/17.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/18.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/19.jpg
ADDED
![]() |
Git LFS Details
|
cotton-plant-disease-data/Aphids/2.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/20.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/21.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/22.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/23.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/24.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/25.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/26.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/27.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/28.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/29.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/3.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/30.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/31.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/32.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/33.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/34.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/35.jpg
ADDED
![]() |
Git LFS Details
|
cotton-plant-disease-data/Aphids/36.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/37.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/38.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/39.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/4.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/40.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/5.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/6.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/7.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/8.jpg
ADDED
![]() |
cotton-plant-disease-data/Aphids/9.jpg
ADDED
![]() |