CoolFace
Apppublic

Gayathri17devi/Toxic.Detection

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
app.py24 linesDownload Raw Back to root
1import gradio as gr2from transformers import pipeline3 4# Load model using pipeline (simpler & reliable)5classifier = pipeline(6    "text-classification",7    model="unitary/toxic-bert",8    return_all_scores=True9)10 11def detect_toxicity(text):12    results = classifier(text)[0]13    return {item['label']: float(item['score']) for item in results}14 15# Gradio UI16iface = gr.Interface(17    fn=detect_toxicity,18    inputs=gr.Textbox(placeholder="Enter a sentence to analyze toxicity levels"),19    outputs=gr.Label(num_top_classes=6),20    title="Toxicity Detection App",21    description="Enter a sentence to check toxicity levels."22)23 24iface.launch()