Update app.py
Browse files
app.py
CHANGED
@@ -208,11 +208,11 @@ def inference(img):
|
|
208 |
# Some models include an additional 'background' class in the predictions, so
|
209 |
# we must account for this when reading the class labels.
|
210 |
includes_background_class = probabilities.shape[1] == 1001
|
211 |
-
|
212 |
for i, item in enumerate(top_5):
|
213 |
class_index = item if includes_background_class else item + 1
|
214 |
line = f'({i+1}) {class_index:4} - {classes[class_index]}: {probabilities[0][top_5][i]}'
|
|
|
|
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
gr.Interface(inference,gr.inputs.Image(type="filepath"),"text").launch()
|
|
|
208 |
# Some models include an additional 'background' class in the predictions, so
|
209 |
# we must account for this when reading the class labels.
|
210 |
includes_background_class = probabilities.shape[1] == 1001
|
211 |
+
result = {}
|
212 |
for i, item in enumerate(top_5):
|
213 |
class_index = item if includes_background_class else item + 1
|
214 |
line = f'({i+1}) {class_index:4} - {classes[class_index]}: {probabilities[0][top_5][i]}'
|
215 |
+
result[classes[class_index]] = result[probabilities[0][top_5][i]]
|
216 |
+
return result
|
217 |
|
218 |
+
gr.Interface(inference,gr.inputs.Image(type="filepath"),"label").launch()
|
|
|
|