Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ def predict(img):
|
|
| 15 |
# Get predictions from the model
|
| 16 |
pred, pred_idx, probs = learn.predict(img)
|
| 17 |
# Convert probabilities to percentages and construct the output dictionary dynamically
|
| 18 |
-
return {
|
| 19 |
except Exception as e:
|
| 20 |
# Log the exception and return it as an error message
|
| 21 |
print(f"An error occurred: {e}")
|
|
|
|
| 15 |
# Get predictions from the model
|
| 16 |
pred, pred_idx, probs = learn.predict(img)
|
| 17 |
# Convert probabilities to percentages and construct the output dictionary dynamically
|
| 18 |
+
return {labels[i]: f"{float(probs[i])*100:.2f}%" for i in range(len(labels))}
|
| 19 |
except Exception as e:
|
| 20 |
# Log the exception and return it as an error message
|
| 21 |
print(f"An error occurred: {e}")
|