shahp7575 commited on
Commit
2f3280b
1 Parent(s): dbaa32b

add app file

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ learn = load_learner("model/what_brew_machine_v1.pkl")
5
+
6
+ categories = tuple(learn.dls.vocab)
7
+
8
+ def what_machine(img):
9
+ pred, idx, probs = learn.predict(img)
10
+ return dict(zip(categories, map(float, probs)))
11
+
12
+ image = gr.inputs.Image(shape=(192,192))
13
+ label = gr.outputs.Label()
14
+ examples = ['sample_imgs/aeropress_go.jpg',
15
+ 'sample_imgs/delonghi_espresso.jpg',
16
+ 'sample_imgs/moka_pot_red.jpeg']
17
+
18
+ intf = gr.Interface(fn=what_machine, inputs=image, outputs=label, examples=examples)
19
+ intf.launch(inline=False)