jentz2909 commited on
Commit
2860169
·
1 Parent(s): f21b318
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -18,7 +18,7 @@ with open(output_path,'r') as file:
18
  LABELS = [x.strip() for x in file.readlines()]
19
 
20
  num_classes = 4000
21
- IMG_SIZE = 224
22
 
23
  def _normalize_img(img):
24
  img = tf.cast(img, tf.float32)/255. # All images will be rescaled by 1./255
@@ -35,10 +35,9 @@ def predict_fn(img):
35
  temp = model.predict(x)
36
 
37
  idx = np.argsort(np.squeeze(temp))[::-1]
38
- sorted_labels = [LABELS[i] for i in idx]
39
- sorted_values = [temp[0][i] for i in idx]
40
 
41
- return {label: str(value) for label, value in zip(sorted_labels, sorted_values)}
42
-
43
 
44
  gr.Interface(predict_fn, gr.Image(type='pil'), outputs='label', examples=path,).launch()
 
18
  LABELS = [x.strip() for x in file.readlines()]
19
 
20
  num_classes = 4000
21
+ IMG_SIZE = 400
22
 
23
  def _normalize_img(img):
24
  img = tf.cast(img, tf.float32)/255. # All images will be rescaled by 1./255
 
35
  temp = model.predict(x)
36
 
37
  idx = np.argsort(np.squeeze(temp))[::-1]
38
+ top3_value = np.asarray([temp[0][i] for i in idx[0:3]])
39
+ top3_idx = idx[0:3]
40
 
41
+ return {LABELS[i]:str(v) for i,v in zip(top3_idx,top3_value)}
 
42
 
43
  gr.Interface(predict_fn, gr.Image(type='pil'), outputs='label', examples=path,).launch()