segadeds commited on
Commit
a1d3bc3
·
1 Parent(s): 9440e36

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+
5
+ learn = load_learner('model.pkl')
6
+
7
+
8
+
9
+ categories = (['calling', 'clapping', 'cycling', 'dancing', 'drinking', 'eating', 'fighting', 'hugging',
10
+ 'laughing', 'listening_to_music', 'running', 'sitting', 'sleeping', 'texting', 'using_laptop'])
11
+
12
+
13
+
14
+ def classify_image(img):
15
+ pred,idx,probs = learn.predict(img)
16
+ return dict(zip(categories, map(float,probs)))
17
+
18
+
19
+
20
+ image = gr.inputs.Image(shape=(192,192))
21
+ label = gr.outputs.Label()
22
+ examples = ['laughing.jpg', 'dancing.jpg', 'drinking.jpg']
23
+
24
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
25
+ intf.launch(inline=False)
26
+
27
+
28
+
29
+
30
+