File size: 4,764 Bytes
ab59988
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
language:
  - en
thumbnail: "/assets/image.jpg"
tags:
  - image-classification
  - computer-vision
  - agriculture
  - maize-diseases
  - agroeye
  - eligapris
  - grey
license: mit
metrics:
  - accuracy
pipeline_tag: image-classification
---

# agroEye

This model is designed to detect diseases in maize (corn) leaves using computer vision techniques.

## Model description

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.

### Intended uses & limitations

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.

**Limitations:**
- The model is trained on a specific dataset and may not generalize well to significantly different growing conditions or maize varieties.
- It is not designed to detect diseases other than the four categories it was trained on.
- Performance on images with multiple diseases present has not been extensively tested.
- The model should not be used as a replacement for professional agricultural advice.

### How to use

Here's a basic example of how to use the model:

```python
import tensorflow as tf
from PIL import Image
import numpy as np
import json

import tensorflow as tf
from huggingface_hub import snapshot_download

# Download the entire model directory
model_dir = snapshot_download(repo_id="eligapris/agroeye",
    local_dir="path/to/model")

# Load the model
model = tf.saved_model.load('path/to/model')

# Now you can use the model for inference

# Load and preprocess the image
img = Image.open('/path/to/image.jpg')
img = img.resize((300, 300 * img.size[1] // img.size[0]))  
img_array = np.array(img)[None]

# Make prediction
inp = tensorflow.constant(img_array, dtype='float32')
prediction = model(inp)[0].numpy()

# Load class names
with open('path/to/model/classes.json', 'r') as f:
    class_names = json.load(f)

# Get the predicted class
predicted_class = list(class_names.keys())[prediction.argmax()]
print(f"Predicted class: {predicted_class}")
```


Here's a detailed output of model prediction:

```python
import tensorflow as tf
from PIL import Image
import numpy as np
import json

import tensorflow as tf
from huggingface_hub import snapshot_download

# Download the entire model directory
model_dir = snapshot_download(repo_id="eligapris/agroeye",
    local_dir="path/to/model")

# Load the model
model = tf.saved_model.load('path/to/model')

# Now you can use the model for inference

# Load and preprocess the image
img = Image.open('/path/to/image.jpg')
img = img.resize((300, 300 * img.size[1] // img.size[0]))  
img_array = np.array(img)[None]

# Make prediction
inp = tensorflow.constant(img_array, dtype='float32')
prediction = model(inp)[0].numpy()

# Load class names and details
with open('model/classes_detailed.json', 'r') as f:
    data = json.load(f)

class_names = data['classes']
class_details = data['details']

# Get the predicted class
predicted_class = list(class_names.keys())[prediction.argmax()]
predicted_class_label = class_names[predicted_class]

print(f"Predicted class: {predicted_class} (Label: {predicted_class_label})")

# Print detailed information about the predicted class
if predicted_class in class_details:
    details = class_details[predicted_class]
    print("\nDetailed Information:")
    for key, value in details.items():
        if isinstance(value, list):
            print(f"{key.capitalize()}:")
            for item in value:
                print(f"  - {item}")
        else:
            print(f"{key.capitalize()}: {value}")

# Print general notes
print("\nGeneral Notes:")
for note in data['general_notes']:
    print(f"- {note}")
```

### Test the colab 
```
https://colab.research.google.com/drive/13-S-obR6MZDDP5kgj6ytsbFiNKzzfXbp
```

## Ethical considerations

- The model's predictions should not be used as the sole basis for agricultural decisions that may impact food security or farmers' livelihoods.
- 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.
- Users should be made aware of the model's limitations and the importance of expert validation.

## Model Card Authors

Grey

## Model Card Contact

eligapris