MennatullahHany commited on
Commit
4b08a93
·
verified ·
1 Parent(s): 070f728

requirements.txt

Browse files

gradio
transformers
torch
sentencepiece

Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline(
5
+ "text-classification",
6
+ model="MennatullahHany/Arabic-Speech-Guard",
7
+ tokenizer="MennatullahHany/Arabic-Speech-Guard",
8
+ return_all_scores=True
9
+ )
10
+
11
+ def predict(text):
12
+ if text.strip() == "":
13
+ return "❌ Please enter Arabic text"
14
+
15
+ results = classifier(text)[0]
16
+ output = ""
17
+ for r in results:
18
+ output += f"{r['label']}: {round(r['score']*100, 2)}%\n"
19
+ return output
20
+
21
+ demo = gr.Interface(
22
+ fn=predict,
23
+ inputs=gr.Textbox(lines=4, placeholder="اكتب النص هنا..."),
24
+ outputs="text",
25
+ title="Arabic Speech Guard 🛡️",
26
+ description="Detect offensive Arabic content"
27
+ )
28
+
29
+ demo.launch()