Init new model
Browse files- app.py +26 -0
- plant_model_v5-beta.h5 +3 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy
|
4 |
+
|
5 |
+
|
6 |
+
model = tf.keras.models.load_model('plant_model_v5-beta.h5')
|
7 |
+
class_names = {0: 'Apple___Apple_scab', 1: 'Apple___Black_rot', 2: 'Apple___Cedar_apple_rust', 3: 'Apple___healthy', 4: 'Not a plant', 5: 'Blueberry___healthy', 6: 'Cherry___Powdery_mildew', 7: 'Cherry___healthy', 8: 'Corn___Cercospora_leaf_spot Gray_leaf_spot', 9: 'Corn___Common_rust', 10: 'Corn___Northern_Leaf_Blight', 11: 'Corn___healthy', 12: 'Grape___Black_rot',
|
8 |
+
13: 'Grape___Esca_(Black_Measles)', 14: 'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)', 15: 'Grape___healthy', 16: 'Orange___Haunglongbing_(Citrus_greening)', 17: 'Peach___Bacterial_spot', 18: 'Peach___healthy', 19: 'Pepper,_bell___Bacterial_spot', 20: 'Pepper,_bell___healthy', 21: 'Potato___Early_blight', 22: 'Potato___Late_blight', 23: 'Potato___healthy', 24: 'Raspberry___healthy', 25: 'Soybean___healthy', 26: 'Squash___Powdery_mildew', 27: 'Strawberry___Leaf_scorch', 28: 'Strawberry___healthy', 29: 'Tomato___Bacterial_spot', 30: 'Tomato___Early_blight', 31: 'Tomato___Late_blight', 32: 'Tomato___Leaf_Mold', 33: 'Tomato___Septoria_leaf_spot', 34: 'Tomato___Spider_mites Two-spotted_spider_mite', 35: 'Tomato___Target_Spot', 36: 'Tomato___Tomato_Yellow_Leaf_Curl_Virus', 37: 'Tomato___Tomato_mosaic_virus', 38: 'Tomato___healthy'}
|
9 |
+
|
10 |
+
|
11 |
+
def classify_image(image):
|
12 |
+
# Preprocess the image
|
13 |
+
img = tf.keras.preprocessing.image.load_img(
|
14 |
+
image.name, target_size=(256, 256))
|
15 |
+
img_array = tf.keras.preprocessing.image.img_to_array(img)
|
16 |
+
img_array = tf.expand_dims(img_array, 0) / 255.0
|
17 |
+
|
18 |
+
# Make a prediction
|
19 |
+
prediction = model.predict(img_array)
|
20 |
+
predicted_class = tf.argmax(prediction[0], axis=-1)
|
21 |
+
|
22 |
+
return class_names[predicted_class.numpy()]
|
23 |
+
|
24 |
+
|
25 |
+
iface = gr.Interface(fn=classify_image, inputs="image", outputs="text")
|
26 |
+
iface.launch()
|
plant_model_v5-beta.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:355bb4d8fdca1f3674a3f3c592353471fdd340ddc3c0ec211346a7de203c2598
|
3 |
+
size 15806664
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tensorflow
|
2 |
+
numpy
|
3 |
+
pillow
|
4 |
+
tensorflow_hub
|