MennatullahHany commited on
Commit
3d731c2
·
verified ·
1 Parent(s): 09f4eeb

Create app.py

Browse files
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
+ # Load model from Hugging Face
5
+ classifier = pipeline(
6
+ "text-classification",
7
+ model="MennatullahHany/Arabic-Speech-Guard",
8
+ tokenizer="MennatullahHany/Arabic-Speech-Guard",
9
+ return_all_scores=True
10
+ )
11
+
12
+ def predict(text):
13
+ if text.strip() == "":
14
+ return "❌ Please enter Arabic text"
15
+
16
+ outputs = classifier(text)[0]
17
+
18
+ result = {item["label"]: round(item["score"], 3) for item in outputs}
19
+ return result
20
+
21
+ interface = gr.Interface(
22
+ fn=predict,
23
+ inputs=gr.Textbox(lines=4, placeholder="اكتب نص عربي هنا..."),
24
+ outputs=gr.JSON(label="Prediction"),
25
+ title="🛡️ Arabic Speech Guard",
26
+ description="Arabic offensive & harmful speech detection model"
27
+ )
28
+
29
+ interface.launch()