devdata commited on
Commit
f7e7db6
·
1 Parent(s): 85fe348

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+
6
+ learn = load_learner('model.pkl')
7
+ #from huggingface_hub import from_pretrained_fastai
8
+ #learn = from_pretrained_fastai("devdatanalytics/commonbean")
9
+
10
+ labels = learn.dls.vocab
11
+ def predict(img):
12
+ img = PILImage.create(img)
13
+ pred,pred_idx,probs = learn.predict(img)
14
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
15
+
16
+ #title = "Common beans diseases classfier"
17
+ #description = "An app for Common beans diseases Classisfication"
18
+ #article="<p style='text-align: center'>The app identifies and classifies common beans diseases: Anthracnose and Bean rust.</p>"
19
+ examples = ['image.jpeg']
20
+ interpretation='default'
21
+ enable_queue=True
22
+
23
+ gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()