Spaces:
Sleeping
Sleeping
Dileep7729
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -61,12 +61,10 @@ 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 |
-
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}")
|
@@ -76,8 +74,7 @@ def classify_image(image):
|
|
76 |
iface = gr.Interface(
|
77 |
fn=classify_image,
|
78 |
inputs=gr.Image(type="pil"),
|
79 |
-
|
80 |
-
outputs=gr.Label(num_top_classes=2),
|
81 |
title="Content Safety Classification",
|
82 |
description="Upload an image to classify it as 'safe' or 'unsafe' with corresponding probabilities.",
|
83 |
)
|
@@ -119,5 +116,6 @@ if __name__ == "__main__":
|
|
119 |
|
120 |
|
121 |
|
|
|
122 |
|
123 |
|
|
|
61 |
unsafe_prob = probs[0][1].item() * 100 # Unsafe percentage
|
62 |
|
63 |
# Return results
|
64 |
+
return {
|
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}")
|
|
|
74 |
iface = gr.Interface(
|
75 |
fn=classify_image,
|
76 |
inputs=gr.Image(type="pil"),
|
77 |
+
outputs=gr.Textbox(label="Output (Debug Mode)"), # Use Textbox to display errors if any occur
|
|
|
78 |
title="Content Safety Classification",
|
79 |
description="Upload an image to classify it as 'safe' or 'unsafe' with corresponding probabilities.",
|
80 |
)
|
|
|
116 |
|
117 |
|
118 |
|
119 |
+
|
120 |
|
121 |
|