eligapris commited on
Commit
915048f
1 Parent(s): ccbc27a

Upload folder using huggingface_hub

Browse files
.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,131 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Maize Disease Detection Model
2
+
3
+ This repository contains a TensorFlow model for detecting diseases in maize (corn) using camera images.
4
+
5
+ ## Model Description
6
+
7
+ This model is designed to classify maize leaf images into four categories:
8
+
9
+ 0. Healthy
10
+ 1. Gray Leaf Spot
11
+ 2. Blight
12
+ 3. Common Rust
13
+
14
+ The model uses computer vision techniques to analyze images of maize leaves and identify the presence of common diseases.
15
+
16
+ ## Usage
17
+
18
+ To use this model for inference, follow these steps:
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
+ 2. Install the required dependencies (assuming you have Python and pip installed):
27
+ ```
28
+ pip install tensorflow pillow numpy
29
+ ```
30
+
31
+ 3. Use the `example.py` script as a reference for how to load and use the model. Here's a basic example:
32
+
33
+ ```python
34
+ import tensorflow as tf
35
+ from PIL import Image
36
+ import numpy as np
37
+ import json
38
+
39
+ # Load the model
40
+ model = tf.keras.models.load_model('saved_model.pb')
41
+
42
+ # Load and preprocess the image
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
+ # Make prediction
49
+ prediction = model.predict(img_array)
50
+
51
+ # Load class names
52
+ with open('classes.json', 'r') as f:
53
+ class_names = json.load(f)
54
+
55
+ # Get the predicted class
56
+ predicted_class = class_names[str(np.argmax(prediction[0]))]
57
+ print(f"Predicted class: {predicted_class}")
58
+ ```
59
+
60
+ Make sure to replace 'image.jpg' with the path to your input image.
61
+
62
+ ## Model Architecture
63
+
64
+ The model architecture is based on a convolutional neural network (CNN) designed for image classification. The exact architecture details are not provided in the repository, but you can infer some information from the `saved_model.pb` file:
65
+
66
+ - The model is saved in TensorFlow's SavedModel format, which preserves the entire tf.keras model, including its architecture and weights.
67
+ - Input images are likely resized to a specific dimension (e.g., 224x224 pixels) before being fed into the network.
68
+ - The output layer corresponds to the four classes defined in `classes.json`.
69
+
70
+ To get more detailed information about the model architecture, you can load the model and use TensorFlow's built-in summary function:
71
+
72
+ ```python
73
+ import tensorflow as tf
74
+
75
+ model = tf.keras.models.load_model('saved_model.pb')
76
+ model.summary()
77
+ ```
78
+
79
+ This will print out the layers and parameters of the model.
80
+
81
+ ## Training Data
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
87
+ - Blight: 1146 images
88
+ - Healthy: 1162 images
89
+
90
+ 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
+ Note: During the formation of this dataset, certain images from the original sources were removed if they were not found to be useful.
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
+ ## Contact
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
+ ## File Structure
124
+
125
+ - `assets/`: Contains additional resources for the model
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
classes.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"Healthy": 0, "Gray_Leaf_Spot": 1, "Blight": 2, "Common_Rust": 3}
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 = [ "Healthy" , "Gray_Leaf_Spot" , "Blight" , "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:0e36d12919e120792bdc0439994cc725f4a047fc3c1911a9b50dc35d90703709
3
+ size 6428971
variables/variables.data-00000-of-00001 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc4f206c90fb449f8987a2111dbbd7b8dbcf9b6d22bfed47b1f6b8a15fee4999
3
+ size 18309528
variables/variables.index ADDED
Binary file (19.1 kB). View file