msibertman commited on
Commit
cb3af6d
·
1 Parent(s): c6a71ed

fixed cap labels

Browse files
Files changed (1) hide show
  1. app.py +3 -24
app.py CHANGED
@@ -3,33 +3,12 @@ import gradio as gr
3
 
4
  # import pathlib
5
  # temp = pathlib.PosixPath
6
- # pathlib.PosixPath = pathlib.WindowsPath
7
-
8
- cap_labels = (
9
- 'balaclava cap',
10
- 'baseball cap',
11
- 'beanie cap',
12
- 'boater hat',
13
- 'bowler hat',
14
- 'bucket hat',
15
- 'cowboy hat',
16
- 'fedora cap',
17
- 'flat cap',
18
- 'ivy cap',
19
- 'kepi cap',
20
- 'newsboy cap',
21
- 'pork pie hat',
22
- 'rasta cap',
23
- 'sun hat',
24
- 'taqiyah cap',
25
- 'top hat',
26
- 'trucker cap',
27
- 'turban cap',
28
- 'visor cap'
29
- )
30
 
31
  model = load_learner('cap-recognizer-v2.pkl')
32
 
 
 
33
  def recognize_image(image):
34
  pred, idx, probs = model.predict(image)
35
  return dict(zip(cap_labels, map(float, probs)))
 
3
 
4
  # import pathlib
5
  # temp = pathlib.PosixPath
6
+ # pathlib.PosixPath = pathlib.WindowsPath
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  model = load_learner('cap-recognizer-v2.pkl')
9
 
10
+ cap_labels = model.dls.vocab
11
+
12
  def recognize_image(image):
13
  pred, idx, probs = model.predict(image)
14
  return dict(zip(cap_labels, map(float, probs)))