Spaces:
Sleeping
Sleeping
Dileep7729
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -69,7 +69,22 @@ def classify_image(image):
|
|
69 |
|
70 |
except Exception as e:
|
71 |
# Log and return detailed error messages
|
72 |
-
print(f"Error during classification:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
|
75 |
|
|
|
69 |
|
70 |
except Exception as e:
|
71 |
# Log and return detailed error messages
|
72 |
+
print(f"Error during classification: {e}")
|
73 |
+
return {"Error": str(e)}
|
74 |
+
|
75 |
+
# Step 3: Set Up Gradio Interface
|
76 |
+
iface = gr.Interface(
|
77 |
+
fn=classify_image,
|
78 |
+
inputs=gr.Image(type="pil"),
|
79 |
+
outputs=gr.Label(label="Classification Results"), # Display probabilities as progress bars
|
80 |
+
title="Content Safety Classification",
|
81 |
+
description="Upload an image to classify it as 'safe' or 'unsafe' with corresponding probabilities.",
|
82 |
+
)
|
83 |
+
|
84 |
+
if __name__ == "__main__":
|
85 |
+
print("Launching the Gradio interface...")
|
86 |
+
iface.launch()
|
87 |
+
|
88 |
|
89 |
|
90 |
|