datasith commited on
Commit
0443ccc
·
1 Parent(s): 3a24180

normalizing results

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -81,11 +81,16 @@ def preprocess(image):
81
  return img_array
82
 
83
  def predict_image(image):
84
- pred = model.predict(preprocess(image))
 
 
 
 
 
 
85
  results = {}
86
- for row in pred:
87
- for idx, item in enumerate(row):
88
- results[labels[idx]] = float(item)
89
  return results
90
 
91
  # generate img input and text label output
 
81
  return img_array
82
 
83
  def predict_image(image):
84
+ # pred = model.predict(preprocess(image))
85
+ # results = {}
86
+ # for row in pred:
87
+ # for idx, item in enumerate(row):
88
+ # results[labels[idx]] = float(item)
89
+ predictions = model.predict(preprocess(image))
90
+ scores = tf.nn.softmax(predictions[0])
91
  results = {}
92
+ for idx, res in enumerate(scores):
93
+ results[labels[idx]] = float(res)
 
94
  return results
95
 
96
  # generate img input and text label output