Spaces:
Runtime error
Runtime error
Create app.py
Browse filesadded the model
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import skimage
|
| 4 |
+
|
| 5 |
+
#installed the fastai
|
| 6 |
+
from fastai import *
|
| 7 |
+
from fastai.vision import *
|
| 8 |
+
#from fastbook import *
|
| 9 |
+
|
| 10 |
+
learn = load_learner('export.pkl')
|
| 11 |
+
|
| 12 |
+
labels = learn.dls.vocab
|
| 13 |
+
def predict(img):
|
| 14 |
+
img = PILImage.create(img)
|
| 15 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 16 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 17 |
+
|
| 18 |
+
title = "CLASMA"
|
| 19 |
+
description = "AI app for classifying disease in cereal crops leaves."
|
| 20 |
+
article = "sample image"
|
| 21 |
+
examples = ['corn.jpg']
|
| 22 |
+
interpretation = 'default'
|
| 23 |
+
enable_queue = True
|
| 24 |
+
|
| 25 |
+
gr.Interface(fn = predict, inputs = gr.inputs.Image(shape = (512, 512)),
|
| 26 |
+
outputs = gr.outputs.Label(num_top_classes = 3),
|
| 27 |
+
title = title,
|
| 28 |
+
description = description,
|
| 29 |
+
article = article,
|
| 30 |
+
examples = examples,
|
| 31 |
+
interpretation = interpretation,
|
| 32 |
+
enable_queue = enable_queue).launch()
|