jaypinedabengco commited on
Commit
1215df2
1 Parent(s): d0cf2eb
Files changed (3) hide show
  1. app.py +14 -5
  2. instructions.txt +0 -0
  3. requirements.txt +1 -0
app.py CHANGED
@@ -1,9 +1,18 @@
1
  import gradio as gr
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- print('hello')
 
 
7
 
8
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
9
- iface.launch()
 
 
1
  import gradio as gr
2
+ from fastai.vision.widgets import *
3
+ # def greet(name):
4
+ # return "Hello " + name + "!!"
5
+ image = gr.inputs.Image(shape=(192, 192))
6
+ label = gr.outputs.Label()
7
+ examples = ['grizzly-bear.jpg', 'black-bear.jpg', 'teddy-bear.jpg']
8
 
9
+ path = Path()
10
+ learn = load_learner(path/'model.pkl')
11
 
12
+ def classify_image(img):
13
+ pred,pred_idx,probs = learn.predict(img)
14
+ return {'Type': pred, 'Probability': f'{probs[pred_idx]:.04f}'}
15
 
16
+
17
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
18
+ iface.launch(inline=False)
instructions.txt DELETED
File without changes
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai>=2.0.0