Spaces:
Runtime error
Runtime error
File size: 787 Bytes
3d731c2 | 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 | import gradio as gr
from transformers import pipeline
# Load model from Hugging Face
classifier = pipeline(
"text-classification",
model="MennatullahHany/Arabic-Speech-Guard",
tokenizer="MennatullahHany/Arabic-Speech-Guard",
return_all_scores=True
)
def predict(text):
if text.strip() == "":
return "❌ Please enter Arabic text"
outputs = classifier(text)[0]
result = {item["label"]: round(item["score"], 3) for item in outputs}
return result
interface = gr.Interface(
fn=predict,
inputs=gr.Textbox(lines=4, placeholder="اكتب نص عربي هنا..."),
outputs=gr.JSON(label="Prediction"),
title="🛡️ Arabic Speech Guard",
description="Arabic offensive & harmful speech detection model"
)
interface.launch()
|