Remy
commited on
Commit
•
5e9ee46
1
Parent(s):
915048f
model card
Browse files
README.md
CHANGED
@@ -1,86 +1,72 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
1. Clone this repository:
|
21 |
-
```
|
22 |
-
git clone https://huggingface.co/eligapris/maize-diseases-detection
|
23 |
-
cd maize-diseases-detection
|
24 |
-
```
|
25 |
|
26 |
-
|
27 |
-
```
|
28 |
-
pip install tensorflow pillow numpy
|
29 |
-
```
|
30 |
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
import tensorflow as tf
|
35 |
-
from PIL import Image
|
36 |
-
import numpy as np
|
37 |
-
import json
|
38 |
|
39 |
-
|
40 |
-
model = tf.keras.models.load_model('saved_model.pb')
|
41 |
|
42 |
-
|
43 |
-
img = Image.open('image.jpg')
|
44 |
-
img = img.resize((224, 224)) # Adjust size as needed
|
45 |
-
img_array = np.array(img) / 255.0 # Normalize pixel values
|
46 |
-
img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
|
47 |
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
-
|
52 |
-
with open('classes.json', 'r') as f:
|
53 |
-
class_names = json.load(f)
|
54 |
|
55 |
-
|
56 |
-
predicted_class = class_names[str(np.argmax(prediction[0]))]
|
57 |
-
print(f"Predicted class: {predicted_class}")
|
58 |
-
```
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
|
62 |
-
|
|
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
- The output layer corresponds to the four classes defined in `classes.json`.
|
69 |
|
70 |
-
|
|
|
|
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
model = tf.keras.models.load_model('saved_model.pb')
|
76 |
-
model.summary()
|
77 |
```
|
78 |
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
The model was trained on a dataset derived from the popular PlantVillage and PlantDoc datasets. The dataset consists of images of corn (maize) leaves in various health states:
|
84 |
|
85 |
- Common Rust: 1306 images
|
86 |
- Gray Leaf Spot: 574 images
|
@@ -91,41 +77,18 @@ Total images: 4188
|
|
91 |
|
92 |
The original dataset can be found on Kaggle: [Corn or Maize Leaf Disease Dataset](https://www.kaggle.com/datasets/smaranjitghose/corn-or-maize-leaf-disease-dataset)
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
## Performance
|
97 |
-
|
98 |
-
[Include information about the model's performance, such as accuracy, precision, recall, or any other relevant metrics once available.]
|
99 |
-
|
100 |
-
## Limitations
|
101 |
-
|
102 |
-
- The model's performance may vary on images that significantly differ from the training dataset in terms of lighting conditions, camera angles, or image quality.
|
103 |
-
- The model is trained to detect four specific conditions (Healthy, Gray Leaf Spot, Blight, and Common Rust). It may not accurately classify other maize diseases or conditions not included in these categories.
|
104 |
-
- The model's performance on images with multiple diseases present has not been extensively tested.
|
105 |
-
|
106 |
-
## License
|
107 |
-
|
108 |
-
This model is released under the MIT License.
|
109 |
|
|
|
|
|
|
|
110 |
|
111 |
Additionally, please credit the original authors of the PlantVillage and PlantDoc datasets, as this model's training data is derived from their work.
|
112 |
|
113 |
-
##
|
114 |
|
115 |
Grey
|
116 |
-
Eligapris
|
117 |
-
|
118 |
-
## Acknowledgements
|
119 |
-
|
120 |
-
- The dataset used for training this model is derived from the PlantVillage and PlantDoc datasets.
|
121 |
-
- Special thanks to the creators and contributors of the [Corn or Maize Leaf Disease Dataset](https://www.kaggle.com/datasets/smaranjitghose/corn-or-maize-leaf-disease-dataset) on Kaggle.
|
122 |
|
123 |
-
##
|
124 |
|
125 |
-
|
126 |
-
- `classes.json`: JSON file containing the mapping of class indices to disease names
|
127 |
-
- `example.py`: Python script demonstrating how to use the model
|
128 |
-
- `image.jpg`: Sample image for testing the model
|
129 |
-
- `README.md`: This file, containing information about the model and how to use it
|
130 |
-
- `saved_model.pb`: The saved TensorFlow model file
|
131 |
-
- `variables/`: Directory containing model variables
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
thumbnail: "/assets/image.jpg"
|
5 |
+
tags:
|
6 |
+
- image-classification
|
7 |
+
- computer-vision
|
8 |
+
- agriculture
|
9 |
+
- maize-diseases
|
10 |
+
license: mit
|
11 |
+
datasets:
|
12 |
+
- smaranjitghose/corn-or-maize-leaf-disease-dataset
|
13 |
+
metrics:
|
14 |
+
- accuracy
|
15 |
+
pipeline_tag: image-classification
|
16 |
+
---
|
17 |
|
18 |
+
# Maize Disease Detection Model
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
This model is designed to detect diseases in maize (corn) leaves using computer vision techniques.
|
|
|
|
|
|
|
21 |
|
22 |
+
## Model description
|
23 |
|
24 |
+
The Maize Disease Detection Model is a convolutional neural network (CNN) trained to classify images of maize leaves into four categories: Healthy, Gray Leaf Spot, Blight, and Common Rust. It aims to assist farmers and agricultural professionals in quickly identifying common maize diseases, potentially leading to earlier interventions and improved crop management.
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
### Intended uses & limitations
|
|
|
27 |
|
28 |
+
The model is intended for use as a diagnostic tool to assist in the identification of maize leaf diseases. It should be used in conjunction with expert knowledge and not as a sole means of diagnosis. The model's performance may vary depending on image quality, lighting conditions, and the presence of diseases or conditions not included in the training dataset.
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
**Limitations:**
|
31 |
+
- The model is trained on a specific dataset and may not generalize well to significantly different growing conditions or maize varieties.
|
32 |
+
- It is not designed to detect diseases other than the four categories it was trained on.
|
33 |
+
- Performance on images with multiple diseases present has not been extensively tested.
|
34 |
+
- The model should not be used as a replacement for professional agricultural advice.
|
35 |
|
36 |
+
### How to use
|
|
|
|
|
37 |
|
38 |
+
Here's a basic example of how to use the model:
|
|
|
|
|
|
|
39 |
|
40 |
+
```python
|
41 |
+
import tensorflow as tf
|
42 |
+
from PIL import Image
|
43 |
+
import numpy as np
|
44 |
+
import json
|
45 |
|
46 |
+
# Load the model
|
47 |
+
model = tf.keras.models.load_model('saved_model.pb')
|
48 |
|
49 |
+
# Load and preprocess the image
|
50 |
+
img = Image.open('image.jpg')
|
51 |
+
img = img.resize((224, 224)) # Adjust size as needed
|
52 |
+
img_array = np.array(img) / 255.0 # Normalize pixel values
|
53 |
+
img_array = np.expand_dims(img_array, axis=0) # Add batch dimension
|
54 |
|
55 |
+
# Make prediction
|
56 |
+
prediction = model.predict(img_array)
|
|
|
57 |
|
58 |
+
# Load class names
|
59 |
+
with open('classes.json', 'r') as f:
|
60 |
+
class_names = json.load(f)
|
61 |
|
62 |
+
# Get the predicted class
|
63 |
+
predicted_class = class_names[str(np.argmax(prediction[0]))]
|
64 |
+
print(f"Predicted class: {predicted_class}")
|
|
|
|
|
65 |
```
|
66 |
|
67 |
+
### Training data
|
68 |
|
69 |
+
The model was trained on a dataset derived from the PlantVillage and PlantDoc datasets, specifically curated for maize leaf diseases. The dataset consists of:
|
|
|
|
|
70 |
|
71 |
- Common Rust: 1306 images
|
72 |
- Gray Leaf Spot: 574 images
|
|
|
77 |
|
78 |
The original dataset can be found on Kaggle: [Corn or Maize Leaf Disease Dataset](https://www.kaggle.com/datasets/smaranjitghose/corn-or-maize-leaf-disease-dataset)
|
79 |
|
80 |
+
## Ethical considerations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
- The model's predictions should not be used as the sole basis for agricultural decisions that may impact food security or farmers' livelihoods.
|
83 |
+
- There may be biases in the training data that could lead to reduced performance for certain maize varieties or growing conditions not well-represented in the dataset.
|
84 |
+
- Users should be made aware of the model's limitations and the importance of expert validation.
|
85 |
|
86 |
Additionally, please credit the original authors of the PlantVillage and PlantDoc datasets, as this model's training data is derived from their work.
|
87 |
|
88 |
+
## Model Card Authors
|
89 |
|
90 |
Grey
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
+
## Model Card Contact
|
93 |
|
94 |
+
eligapris
|
|
|
|
|
|
|
|
|
|
|
|