Toqi Tahamid commited on
Commit
7fd0d00
1 Parent(s): 2c44690

update app.py

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