Create app.py
Browse files
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]['
|
11 |
|
12 |
# إنشاء واجهة مستخدم
|
13 |
-
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|