DavidRussell commited on
Commit
660b43f
·
1 Parent(s): bf9d38d

add application file

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