Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +155 -3
- classes.json +1 -0
- classes_detailed.json +76 -0
- example.py +23 -0
- image.jpg +0 -0
- saved_model.pb +3 -0
- variables/variables.data-00000-of-00001 +3 -0
- variables/variables.index +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ 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 |
+
variables/variables.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,155 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
thumbnail: "/assets/image.jpg"
|
| 5 |
+
tags:
|
| 6 |
+
- image-classification
|
| 7 |
+
- computer-vision
|
| 8 |
+
- agriculture
|
| 9 |
+
- maize-diseases
|
| 10 |
+
- agroeye
|
| 11 |
+
- eligapris
|
| 12 |
+
- grey
|
| 13 |
+
license: mit
|
| 14 |
+
metrics:
|
| 15 |
+
- accuracy
|
| 16 |
+
pipeline_tag: image-classification
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# agroEye
|
| 20 |
+
|
| 21 |
+
This model is designed to detect diseases in maize (corn) leaves using computer vision techniques.
|
| 22 |
+
|
| 23 |
+
## Model description
|
| 24 |
+
|
| 25 |
+
The agroEye 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.
|
| 26 |
+
|
| 27 |
+
### Intended uses & limitations
|
| 28 |
+
|
| 29 |
+
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.
|
| 30 |
+
|
| 31 |
+
**Limitations:**
|
| 32 |
+
- The model is trained on a specific dataset and may not generalize well to significantly different growing conditions or maize varieties.
|
| 33 |
+
- It is not designed to detect diseases other than the four categories it was trained on.
|
| 34 |
+
- Performance on images with multiple diseases present has not been extensively tested.
|
| 35 |
+
- The model should not be used as a replacement for professional agricultural advice.
|
| 36 |
+
|
| 37 |
+
### How to use
|
| 38 |
+
|
| 39 |
+
Here's a basic example of how to use the model:
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
import tensorflow as tf
|
| 43 |
+
from PIL import Image
|
| 44 |
+
import numpy as np
|
| 45 |
+
import json
|
| 46 |
+
|
| 47 |
+
import tensorflow as tf
|
| 48 |
+
from huggingface_hub import snapshot_download
|
| 49 |
+
|
| 50 |
+
# Download the entire model directory
|
| 51 |
+
model_dir = snapshot_download(repo_id="eligapris/agroeye",
|
| 52 |
+
local_dir="path/to/model")
|
| 53 |
+
|
| 54 |
+
# Load the model
|
| 55 |
+
model = tf.saved_model.load('path/to/model')
|
| 56 |
+
|
| 57 |
+
# Now you can use the model for inference
|
| 58 |
+
|
| 59 |
+
# Load and preprocess the image
|
| 60 |
+
img = Image.open('/path/to/image.jpg')
|
| 61 |
+
img = img.resize((300, 300 * img.size[1] // img.size[0]))
|
| 62 |
+
img_array = np.array(img)[None]
|
| 63 |
+
|
| 64 |
+
# Make prediction
|
| 65 |
+
inp = tensorflow.constant(img_array, dtype='float32')
|
| 66 |
+
prediction = model(inp)[0].numpy()
|
| 67 |
+
|
| 68 |
+
# Load class names
|
| 69 |
+
with open('path/to/model/classes.json', 'r') as f:
|
| 70 |
+
class_names = json.load(f)
|
| 71 |
+
|
| 72 |
+
# Get the predicted class
|
| 73 |
+
predicted_class = list(class_names.keys())[prediction.argmax()]
|
| 74 |
+
print(f"Predicted class: {predicted_class}")
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
Here's a detailed output of model prediction:
|
| 79 |
+
|
| 80 |
+
```python
|
| 81 |
+
import tensorflow as tf
|
| 82 |
+
from PIL import Image
|
| 83 |
+
import numpy as np
|
| 84 |
+
import json
|
| 85 |
+
|
| 86 |
+
import tensorflow as tf
|
| 87 |
+
from huggingface_hub import snapshot_download
|
| 88 |
+
|
| 89 |
+
# Download the entire model directory
|
| 90 |
+
model_dir = snapshot_download(repo_id="eligapris/agroeye",
|
| 91 |
+
local_dir="path/to/model")
|
| 92 |
+
|
| 93 |
+
# Load the model
|
| 94 |
+
model = tf.saved_model.load('path/to/model')
|
| 95 |
+
|
| 96 |
+
# Now you can use the model for inference
|
| 97 |
+
|
| 98 |
+
# Load and preprocess the image
|
| 99 |
+
img = Image.open('/path/to/image.jpg')
|
| 100 |
+
img = img.resize((300, 300 * img.size[1] // img.size[0]))
|
| 101 |
+
img_array = np.array(img)[None]
|
| 102 |
+
|
| 103 |
+
# Make prediction
|
| 104 |
+
inp = tensorflow.constant(img_array, dtype='float32')
|
| 105 |
+
prediction = model(inp)[0].numpy()
|
| 106 |
+
|
| 107 |
+
# Load class names and details
|
| 108 |
+
with open('model/classes_detailed.json', 'r') as f:
|
| 109 |
+
data = json.load(f)
|
| 110 |
+
|
| 111 |
+
class_names = data['classes']
|
| 112 |
+
class_details = data['details']
|
| 113 |
+
|
| 114 |
+
# Get the predicted class
|
| 115 |
+
predicted_class = list(class_names.keys())[prediction.argmax()]
|
| 116 |
+
predicted_class_label = class_names[predicted_class]
|
| 117 |
+
|
| 118 |
+
print(f"Predicted class: {predicted_class} (Label: {predicted_class_label})")
|
| 119 |
+
|
| 120 |
+
# Print detailed information about the predicted class
|
| 121 |
+
if predicted_class in class_details:
|
| 122 |
+
details = class_details[predicted_class]
|
| 123 |
+
print("\nDetailed Information:")
|
| 124 |
+
for key, value in details.items():
|
| 125 |
+
if isinstance(value, list):
|
| 126 |
+
print(f"{key.capitalize()}:")
|
| 127 |
+
for item in value:
|
| 128 |
+
print(f" - {item}")
|
| 129 |
+
else:
|
| 130 |
+
print(f"{key.capitalize()}: {value}")
|
| 131 |
+
|
| 132 |
+
# Print general notes
|
| 133 |
+
print("\nGeneral Notes:")
|
| 134 |
+
for note in data['general_notes']:
|
| 135 |
+
print(f"- {note}")
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
### Test the colab
|
| 139 |
+
```
|
| 140 |
+
https://colab.research.google.com/drive/13-S-obR6MZDDP5kgj6ytsbFiNKzzfXbp
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
## Ethical considerations
|
| 144 |
+
|
| 145 |
+
- The model's predictions should not be used as the sole basis for agricultural decisions that may impact food security or farmers' livelihoods.
|
| 146 |
+
- 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.
|
| 147 |
+
- Users should be made aware of the model's limitations and the importance of expert validation.
|
| 148 |
+
|
| 149 |
+
## Model Card Authors
|
| 150 |
+
|
| 151 |
+
Grey
|
| 152 |
+
|
| 153 |
+
## Model Card Contact
|
| 154 |
+
|
| 155 |
+
eligapris
|
classes.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"Northern_Leaf_Blight": 0, "Gray_Leaf_Spot": 1, "Healthy_Leaf": 2, "Common_Rust": 3}
|
classes_detailed.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"classes": {
|
| 3 |
+
"Healthy": 0,
|
| 4 |
+
"Gray_Leaf_Spot": 1,
|
| 5 |
+
"Blight": 2,
|
| 6 |
+
"Common_Rust": 3
|
| 7 |
+
},
|
| 8 |
+
"details": {
|
| 9 |
+
"Healthy": {
|
| 10 |
+
"description": "Plants show no signs of disease.",
|
| 11 |
+
"characteristics": [
|
| 12 |
+
"Vibrant green color",
|
| 13 |
+
"Uniform leaf structure",
|
| 14 |
+
"No spots or lesions",
|
| 15 |
+
"Normal growth and development"
|
| 16 |
+
],
|
| 17 |
+
"importance": "Represents the ideal state of the crop, with maximum yield potential."
|
| 18 |
+
},
|
| 19 |
+
"Gray_Leaf_Spot": {
|
| 20 |
+
"causative_agent": "Cercospora zeae-maydis, C. sorghi var. maydis",
|
| 21 |
+
"symptoms": [
|
| 22 |
+
"Small, regular, elongated brown-gray necrotic spots growing parallel to the veins",
|
| 23 |
+
"Lesions may reach 3.0 x 0.3 cm",
|
| 24 |
+
"Lesions may coalesce, producing a complete burning of large areas of the leaves"
|
| 25 |
+
],
|
| 26 |
+
"environmental_conditions": [
|
| 27 |
+
"Prevalent in subtropical and temperate, humid areas",
|
| 28 |
+
"Favored by extended periods of leaf wetness and cloudy conditions"
|
| 29 |
+
],
|
| 30 |
+
"impact": "Can result in severe leaf senescence following flowering and poor grain fill",
|
| 31 |
+
"notes": [
|
| 32 |
+
"Also known as cercospora leaf spot",
|
| 33 |
+
"Minimum tillage practices have been associated with increased incidence"
|
| 34 |
+
]
|
| 35 |
+
},
|
| 36 |
+
"Blight": {
|
| 37 |
+
"note": "This typically refers to Northern Corn Leaf Blight, but could include other types of blight",
|
| 38 |
+
"causative_agent": "Setosphaeria turcica (Teleomorph), Exserohilum turcicum (Anamorph)",
|
| 39 |
+
"symptoms": [
|
| 40 |
+
"Small, oval, water-soaked spots on leaves",
|
| 41 |
+
"Spots grow into elongated, spindle-shaped necrotic lesions",
|
| 42 |
+
"Lesions may appear first on lower leaves and increase in number as the plant develops",
|
| 43 |
+
"Can lead to complete burning of the foliage"
|
| 44 |
+
],
|
| 45 |
+
"environmental_conditions": [
|
| 46 |
+
"Occurs worldwide, particularly in areas with high humidity and moderate temperatures",
|
| 47 |
+
"Prevalent during the growing season"
|
| 48 |
+
],
|
| 49 |
+
"impact": "When infection occurs prior to and at silking and conditions are optimum, it may cause significant economic damage"
|
| 50 |
+
},
|
| 51 |
+
"Common_Rust": {
|
| 52 |
+
"causative_agent": "Puccinia sorghi",
|
| 53 |
+
"symptoms": [
|
| 54 |
+
"Small, elongate, powdery pustules over both surfaces of the leaves",
|
| 55 |
+
"Pustules are dark brown in early stages of infection",
|
| 56 |
+
"Later, the epidermis is ruptured and the lesions turn black as the plant matures"
|
| 57 |
+
],
|
| 58 |
+
"environmental_conditions": [
|
| 59 |
+
"Found worldwide in subtropical, temperate, and highland environments with high humidity"
|
| 60 |
+
],
|
| 61 |
+
"impact": "Can reduce yield, especially if infection is severe before or during tasseling",
|
| 62 |
+
"notes": [
|
| 63 |
+
"Most conspicuous when plants approach tasseling",
|
| 64 |
+
"Alternate host (Oxalis spp.) may show light orange colored pustules"
|
| 65 |
+
]
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"general_notes": [
|
| 69 |
+
"Early detection and proper identification of these diseases are crucial for effective management.",
|
| 70 |
+
"Integrated pest management strategies, including resistant varieties, crop rotation, and timely fungicide applications, can help control these diseases.",
|
| 71 |
+
"Climate conditions, particularly humidity and temperature, play a significant role in the development and spread of these diseases.",
|
| 72 |
+
"Many diseases can have similar symptoms, so careful observation and sometimes laboratory analysis may be necessary for accurate diagnosis.",
|
| 73 |
+
"The severity of disease impact often depends on the timing of infection relative to the plant's growth stage.",
|
| 74 |
+
"Some pathogens can infect multiple parts of the plant, including leaves, stalks, and ears."
|
| 75 |
+
]
|
| 76 |
+
}
|
example.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# TF for image classification model
|
| 3 |
+
|
| 4 |
+
import tensorflow
|
| 5 |
+
import numpy
|
| 6 |
+
from PIL import Image
|
| 7 |
+
|
| 8 |
+
model = tensorflow.saved_model.load('./')
|
| 9 |
+
classes = [ "Northern_Leaf_Blight" , "Gray_Leaf_Spot" , "Healthy_Leaf" , "Common_Rust" , ]
|
| 10 |
+
|
| 11 |
+
img = Image.open("image.jpg").convert('RGB')
|
| 12 |
+
img = img.resize((300, 300 * img.size[1] // img.size[0]), Image.ANTIALIAS)
|
| 13 |
+
inp_numpy = numpy.array(img)[None]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
inp = tensorflow.constant(inp_numpy, dtype='float32')
|
| 17 |
+
|
| 18 |
+
class_scores = model(inp)[0].numpy()
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
print("")
|
| 22 |
+
print("class_scores", class_scores)
|
| 23 |
+
print("Class : ", classes[class_scores.argmax()])
|
image.jpg
ADDED
|
saved_model.pb
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:643a3ac8a4c92c47a2f54bc4561d00c168e7bda725c15315d5b407e2e6a5fa1d
|
| 3 |
+
size 6448188
|
variables/variables.data-00000-of-00001
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3da3190395e6a00fbc78f5c5f964335d0664d4ae9a1bc01e6531686270b2d366
|
| 3 |
+
size 18311730
|
variables/variables.index
ADDED
|
Binary file (19.3 kB). View file
|
|
|