File size: 724 Bytes
1ca89b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ca5453
 
 
f4b450a
1ca89b6
 
 
f4b450a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from transformers import pipeline

# Cargar el modelo de detecci贸n NSFW
nsfw_detector = pipeline("text-classification", model="ezb/NSFW-Prompt-Detector")

def detect_nsfw(text):
    # Realizar la predicci贸n
    result = nsfw_detector(text)
    # Devolver la etiqueta y la puntuaci贸n
    return result[0]['label'], result[0]['score']

# Definir la interfaz de Gradio
iface = gr.Interface(
    fn=detect_nsfw,
    inputs=gr.Textbox(lines=2, placeholder="Introduce the text here..."),
    outputs=[gr.Text(label="Label"), gr.Number(label="Confidence")],
    title="NSFW Text Detector",
    description="This model detects NSFW content in text."
)

if __name__ == "__main__":
    iface.launch(share=True)