Spaces:
Runtime error
Runtime error
normalizing results
Browse files
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
|
87 |
-
|
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
|