Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,14 +27,19 @@ def predict_image(image):
|
|
27 |
# Streamlit app
|
28 |
st.title("NSFW Image Classifier")
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
if
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
27 |
# Streamlit app
|
28 |
st.title("NSFW Image Classifier")
|
29 |
|
30 |
+
# URL input
|
31 |
+
image_url = st.text_input("Enter Image URL", placeholder="Enter image URL here")
|
32 |
+
if image_url:
|
33 |
+
try:
|
34 |
+
# Load image from URL
|
35 |
+
response = requests.get(image_url)
|
36 |
+
image = Image.open(BytesIO(response.content))
|
37 |
+
st.image(image, caption='Image from URL', use_column_width=True)
|
38 |
+
st.write("")
|
39 |
+
st.write("Classifying...")
|
40 |
|
41 |
+
# Predict and display result
|
42 |
+
prediction = predict_image(image)
|
43 |
+
st.write(f"Predicted Class: {prediction}")
|
44 |
+
except Exception as e:
|
45 |
+
st.write(f"Error: {e}")
|