g0blas commited on
Commit
0aa6c36
·
1 Parent(s): f59dfb2

update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -4
app.py CHANGED
@@ -1,7 +1,40 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ cap_labels = cap_labels = {
4
+ 'baseball cap',
5
+ 'beanie cap',
6
+ 'fedora cap',
7
+ 'cowboy hat',
8
+ 'kepi cap',
9
+ 'flat cap',
10
+ 'trucker cap',
11
+ # 'newsboy cap'
12
+ 'pork pie hat',
13
+ 'bowler hat',
14
+ 'top hat',
15
+ 'sun hat',
16
+ 'boater hat',
17
+ # 'ivy cap',
18
+ 'bucket hat',
19
+ 'balaclava cap',
20
+ 'turban cap',
21
+ 'taqiyah cap',
22
+ 'rasta cap',
23
+ 'visor cap'
24
+ }
25
 
26
+ def recognize_image(image):
27
+ pred, idx, probs = model.predict(image)
28
+ return dict(zip(sorted(cap_labels), map(float, probs)))
29
+
30
+ image = gr.inputs.Image(shape=(192, 192))
31
+ label = gr.outputs.Label()
32
+ examples = [
33
+ 'test_images/test_0.jpg',
34
+ 'test_images/test_1.jpg',
35
+ 'test_images/test_2.jpg',
36
+ 'test_images/test_3.jpg',
37
+ 'test_images/test_4.jpg',
38
+ 'test_images/test_5.jpg']
39
+ iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
40
+ iface.launch(inline=False, share=True)