Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| # ุชุญู ูู ุงูู ูุฏูู | |
| classifier = pipeline( | |
| "text-classification", | |
| model="MennatullahHany/Arabic-Speech-Guard", | |
| tokenizer="MennatullahHany/Arabic-Speech-Guard", | |
| return_all_scores=True | |
| ) | |
| # mapping labels | |
| label_map = { | |
| "LABEL_0": "SAFE โ ", | |
| "LABEL_1": "DANGER โ ๏ธ" | |
| } | |
| def predict(text): | |
| if text.strip() == "": | |
| return "โ Please enter Arabic text" | |
| results = classifier(text)[0] # ูุงุฆู ุฉ ู ู ุงูููู ููู label | |
| output = "" | |
| for r in results: | |
| mapped_label = label_map.get(r['label'], r['label']) | |
| output += f"{mapped_label}: {round(r['score']*100, 2)}%\n" | |
| return output | |
| # ูุงุฌูุฉ Gradio | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Textbox(lines=4, placeholder="ุงูุชุจ ุงููุต ููุง..."), | |
| outputs="text", | |
| title="Arabic Speech Guard ๐ก๏ธ", | |
| description="Detect offensive Arabic content" | |
| ) | |
| demo.launch() | |