Spaces:
Sleeping
Sleeping
File size: 1,043 Bytes
f6475f8 0bc527f f6475f8 0bc527f f6475f8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import streamlit as st
from transformers import pipeline
from PIL import Image
# Title of the web app
st.title("NSFW Image Detection with Hugging Face")
# Description
st.write("""
This is a simple web application that uses a Hugging Face model to detect NSFW content in images.
Upload an image and the model will classify whether it contains NSFW content.
""")
# Upload image
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
# Display the uploaded image
image = Image.open(uploaded_file)
st.image(image, caption="Uploaded Image", use_column_width=True)
# Load the model using the pipeline
pipe = pipeline("image-classification", model="Falconsai/nsfw_image_detection")
# Classify the image
with st.spinner('Classifying...'):
results = pipe(image)
# Display the classification results
st.write("Classification Results:")
for result in results:
st.write(f"Label: {result['label']}, Score: {result['score']:.4f}")
|