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()