Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,27 @@
|
|
| 1 |
-
import
|
| 2 |
-
import requests
|
| 3 |
import gradio as gr
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
inception_net = tf.keras.applications.MobileNetV2()
|
| 6 |
-
response = requests.get("https://git.io/JJkYN")
|
| 7 |
-
labels = response.text.split("\n")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
return confidences
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
demo.launch()
|
|
|
|
| 1 |
+
import tf_keras as keras
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
+
import cv2
|
| 4 |
+
import os
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
print(os.listdir('./model'))
|
| 8 |
+
used_model = keras.models.load_model('./model')
|
| 9 |
+
new_classes = ['Potato___Early_blight', 'Potato___Late_blight', 'Potato___healthy']
|
| 10 |
+
|
| 11 |
+
def classify_image(img_dt):
|
| 12 |
+
img_dt = cv2.resize(img_dt,(256,256))
|
| 13 |
+
img_dt = img_dt.reshape((-1,256,256,3))
|
| 14 |
+
prediction = used_model.predict(img_dt).flatten()
|
| 15 |
+
confidences = {new_classes[i]: float(prediction[i]) for i in range (4) }
|
| 16 |
return confidences
|
| 17 |
|
| 18 |
+
|
| 19 |
+
with gr.Blocks() as demo:
|
| 20 |
+
signal = gr.Markdown(''' Welcome to Maize Classifier,This model can identify if a leaf is
|
| 21 |
+
**HEALTHY**, has **'Potato___Early_blight'** or **Potato_late___blight**''')
|
| 22 |
+
with gr.Row():
|
| 23 |
+
inp = gr.Image()
|
| 24 |
+
out = gr.Label()
|
| 25 |
+
inp.upload(fn= classify_image, inputs = inp, outputs = out)
|
| 26 |
|
| 27 |
demo.launch()
|