freestok commited on
Commit
da2a94f
·
1 Parent(s): 820d464

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +24 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'intf']
3
+
4
+ # Cell
5
+ from fastai.vision.all import *
6
+ import gradio as gr
7
+
8
+
9
+ # Cell
10
+ learn = load_learner('model.pkl')
11
+
12
+ # Cell
13
+ categories = ('southern-leaf-blight', 'healthy', 'northern-leaf-blight', 'rust')
14
+
15
+ def classify_image(img):
16
+ pred,idx,probs = learn.predict(img)
17
+ return dict(zip(categories, map(float,probs)))
18
+
19
+ # Cell
20
+ image = gr.inputs.Image(shape=(192, 192))
21
+ label = gr.outputs.Label()
22
+
23
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
24
+ intf.launch(inline=False)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+