Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,10 +61,12 @@ def classify_image(image):
|
|
| 61 |
unsafe_prob = probs[0][1].item() * 100 # Unsafe percentage
|
| 62 |
|
| 63 |
# Return results
|
| 64 |
-
|
| 65 |
"safe": f"{safe_prob:.2f}%",
|
| 66 |
"unsafe": f"{unsafe_prob:.2f}%"
|
| 67 |
}
|
|
|
|
|
|
|
| 68 |
|
| 69 |
except Exception as e:
|
| 70 |
print(f"Error during classification: {e}")
|
|
|
|
| 61 |
unsafe_prob = probs[0][1].item() * 100 # Unsafe percentage
|
| 62 |
|
| 63 |
# Return results
|
| 64 |
+
result = {
|
| 65 |
"safe": f"{safe_prob:.2f}%",
|
| 66 |
"unsafe": f"{unsafe_prob:.2f}%"
|
| 67 |
}
|
| 68 |
+
return dict(sorted(result.items(), key=lambda item: item[1], reverse=True))
|
| 69 |
+
|
| 70 |
|
| 71 |
except Exception as e:
|
| 72 |
print(f"Error during classification: {e}")
|