File size: 710 Bytes
1ca89b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.inputs.Textbox(lines=2, placeholder="Introduce el texto aqu铆..."),
    outputs=["text", "number"],
    title="Detector de Texto NSFW",
    description="Introduce un texto para verificar si contiene contenido NSFW."
)

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