nseaber commited on
Commit
1da5c22
·
1 Parent(s): dc6f171
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -1,7 +1,27 @@
 
 
 
 
 
 
 
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: ../rabbit_or_hare_app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'catagories', 'image', 'label', 'examples', 'title', 'intf', 'classify_img']
5
+
6
+ # %% ../rabbit_or_hare_app.ipynb 1
7
+ from fastai.vision.all import *
8
  import gradio as gr
9
 
10
+ # %% ../rabbit_or_hare_app.ipynb 2
11
+ learn = load_learner('model.pkl')
12
+
13
+ # %% ../rabbit_or_hare_app.ipynb 3
14
+ catagories = ('Hare', 'Rabbit')
15
+
16
+ def classify_img(img):
17
+ pred, idx, probs = learn.predict(img)
18
+ return dict(zip(catagories, map(float, probs)))
19
+
20
+ # %% ../rabbit_or_hare_app.ipynb 4
21
+ image = gr.Image()
22
+ label = gr.Label()
23
+ examples = ['bnuy.jpg', 'sam.jpg', 'aihare.jpg', 'aiwhare.jpg', 'aiwrabbit.jpg']
24
+ title = "Rabbit or Hare?"
25
 
26
+ intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples, title=title)
27
+ intf.launch(inline=False, height=250)