nsfwchecker / app.py
alejandroacho's picture
first commit
1ca89b6
raw
history blame
710 Bytes
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()