Spaces:
Build error
Build error
Upload 2 files
Browse files- app.py +29 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Crop_Disease_Identificationfrom fastai.vision.all import *
|
| 2 |
+
from fastai.vision.all import load_learner
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
fruit_labels = ('Anthracnose', 'Apple Scab', 'Black Spot', 'Blight',
|
| 6 |
+
'Blossom End Rot', 'Botrytis', 'Brown Rot', 'Canker',
|
| 7 |
+
'Cedar Apple Rust', 'Clubroot', 'Crown Gall', 'Downy Mildew',
|
| 8 |
+
'Fire Blight', 'Fusarium', 'Gray Mold', 'Leaf Spots', 'Mosaic Virus',
|
| 9 |
+
'Nematodes', 'Powdery Mildew', 'Verticillium')
|
| 10 |
+
|
| 11 |
+
model=load_learner("crop_model_1.pkl")
|
| 12 |
+
|
| 13 |
+
def recognize_image(image):
|
| 14 |
+
pred, idx, probs = model.predict(image)
|
| 15 |
+
print(pred)
|
| 16 |
+
return dict(zip(fruit_labels, map(float, probs)))
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 20 |
+
label = gr.outputs.Label(num_top_classes=5)
|
| 21 |
+
examples = [
|
| 22 |
+
'image_1.jpg',
|
| 23 |
+
'image_2.jpeg',
|
| 24 |
+
'image_3.jpeg',
|
| 25 |
+
'image_4.jpeg'
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
|
| 29 |
+
iface.launch(inline=False)
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Gradio==3.50.0
|
| 2 |
+
Fastai==2.7.13
|