Utkarsh736 commited on
Commit
a2b1c29
·
1 Parent(s): f9472df

[Added] nbdev converted Bearify app file

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