Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import CLIPModel, CLIPProcessor
|
3 |
from PIL import Image
|
4 |
-
import requests
|
5 |
|
6 |
# Step 1: Load Fine-Tuned Model from Hugging Face Model Hub
|
7 |
model_name = "quadranttechnologies/retail-content-safety-clip-finetuned"
|
@@ -68,7 +67,6 @@ def classify_image(image):
|
|
68 |
}
|
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 |
|
@@ -76,11 +74,12 @@ def classify_image(image):
|
|
76 |
iface = gr.Interface(
|
77 |
fn=classify_image,
|
78 |
inputs=gr.Image(type="pil"),
|
79 |
-
outputs=gr.
|
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()
|
@@ -116,5 +115,6 @@ if __name__ == "__main__":
|
|
116 |
|
117 |
|
118 |
|
|
|
119 |
|
120 |
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import CLIPModel, CLIPProcessor
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
# Step 1: Load Fine-Tuned Model from Hugging Face Model Hub
|
6 |
model_name = "quadranttechnologies/retail-content-safety-clip-finetuned"
|
|
|
67 |
}
|
68 |
|
69 |
except Exception as e:
|
|
|
70 |
print(f"Error during classification: {e}")
|
71 |
return {"Error": str(e)}
|
72 |
|
|
|
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 |
)
|
81 |
|
82 |
+
# Step 4: Launch Gradio Interface
|
83 |
if __name__ == "__main__":
|
84 |
print("Launching the Gradio interface...")
|
85 |
iface.launch()
|
|
|
115 |
|
116 |
|
117 |
|
118 |
+
|
119 |
|
120 |
|