danielmartinec commited on
Commit
89e5f67
·
1 Parent(s): ad352b2

Moving app.py to root

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -1,7 +1,26 @@
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
5
+
6
+ # %% ../app.ipynb 1
7
+ from fastai.vision.all import *
8
  import gradio as gr
9
 
10
+ # %% ../app.ipynb 3
11
+ learn = load_learner('export.pkl')
12
+
13
+ # %% ../app.ipynb 5
14
+ categories = ('grizzly', 'black', 'teddy')
15
+
16
+ def classify_image(im):
17
+ pred, idx, probs = learn.predict(im)
18
+ return dict(zip(categories, map(float, probs)))
19
+
20
+ # %% ../app.ipynb 7
21
+ image = gr.Image(width=192, height=192)
22
+ label = gr.Label()
23
+ examples = ['grizzly.jpg', 'black.jpg', 'teddy.jpg', 'dunno.jpg']
24
 
25
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
26
+ intf.launch(inline=False)