Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -60,10 +60,10 @@ def classify_image(image):
|
|
60 |
safe_prob = probs[0][0].item() * 100 # Safe percentage
|
61 |
unsafe_prob = probs[0][1].item() * 100 # Unsafe percentage
|
62 |
|
63 |
-
#
|
64 |
return {
|
65 |
-
"safe":
|
66 |
-
"unsafe":
|
67 |
}
|
68 |
|
69 |
except Exception as e:
|
@@ -74,7 +74,7 @@ def classify_image(image):
|
|
74 |
iface = gr.Interface(
|
75 |
fn=classify_image,
|
76 |
inputs=gr.Image(type="pil"),
|
77 |
-
outputs=gr.
|
78 |
title="Content Safety Classification",
|
79 |
description="Upload an image to classify it as 'safe' or 'unsafe' with corresponding probabilities.",
|
80 |
)
|
@@ -117,5 +117,6 @@ if __name__ == "__main__":
|
|
117 |
|
118 |
|
119 |
|
|
|
120 |
|
121 |
|
|
|
60 |
safe_prob = probs[0][0].item() * 100 # Safe percentage
|
61 |
unsafe_prob = probs[0][1].item() * 100 # Unsafe percentage
|
62 |
|
63 |
+
# Format data for visualization
|
64 |
return {
|
65 |
+
"safe": safe_prob,
|
66 |
+
"unsafe": unsafe_prob
|
67 |
}
|
68 |
|
69 |
except Exception as e:
|
|
|
74 |
iface = gr.Interface(
|
75 |
fn=classify_image,
|
76 |
inputs=gr.Image(type="pil"),
|
77 |
+
outputs=gr.Label(num_top_classes=2), # Use gr.Label to display probabilities with a bar-style visualization
|
78 |
title="Content Safety Classification",
|
79 |
description="Upload an image to classify it as 'safe' or 'unsafe' with corresponding probabilities.",
|
80 |
)
|
|
|
117 |
|
118 |
|
119 |
|
120 |
+
|
121 |
|
122 |
|