riyanswat commited on
Commit
89e0fbe
·
1 Parent(s): 0040b6f

Upload app.py

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