Mohzen321 commited on
Commit
d436730
·
verified ·
1 Parent(s): cf8314e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -7,8 +7,15 @@ classifier = pipeline("text-classification", model="distilbert-base-uncased")
7
  # دالة لتصنيف النص
8
  def classify_text(text):
9
  result = classifier(text)
10
- return result[0]['label']
11
 
12
  # إنشاء واجهة مستخدم
13
- iface = gr.Interface(fn=classify_text, inputs="text", outputs="text")
 
 
 
 
 
 
 
14
  iface.launch()
 
7
  # دالة لتصنيف النص
8
  def classify_text(text):
9
  result = classifier(text)
10
+ return {label: round(score, 2) for label, score in zip(result[0]['labels'], result[0]['scores'])}
11
 
12
  # إنشاء واجهة مستخدم
13
+ iface = gr.Interface(
14
+ fn=classify_text,
15
+ inputs=gr.Textbox(lines=5, placeholder="Enter text here..."),
16
+ outputs="json",
17
+ title="Text Classification App",
18
+ description="This app classifies your text into predefined categories and shows the confidence scores."
19
+ )
20
+
21
  iface.launch()