Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,11 @@ def classify_image(input_image):
|
|
| 48 |
|
| 49 |
# Perform prediction
|
| 50 |
prediction = inception_net.predict(input_image).flatten()
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
return confidences
|
| 53 |
|
| 54 |
image = gr.Image(interactive=True, label="Upload Image")
|
|
|
|
| 48 |
|
| 49 |
# Perform prediction
|
| 50 |
prediction = inception_net.predict(input_image).flatten()
|
| 51 |
+
|
| 52 |
+
# Get the top indices and their respective confidence scores
|
| 53 |
+
top_indices = np.argsort(prediction)[-3:][::-1] # Get the top 3 indices
|
| 54 |
+
confidences = {labels[i]: float(prediction[i]) for i in top_indices}
|
| 55 |
+
|
| 56 |
return confidences
|
| 57 |
|
| 58 |
image = gr.Image(interactive=True, label="Upload Image")
|