Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,14 +2,7 @@ import streamlit as st
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# تحميل النموذج
|
5 |
-
classifier = pipeline("
|
6 |
-
|
7 |
-
# قائمة العلامات
|
8 |
-
labels = {
|
9 |
-
"LABEL_0": "shopping",
|
10 |
-
"LABEL_1": "gaming",
|
11 |
-
"LABEL_2": "streaming"
|
12 |
-
}
|
13 |
|
14 |
# عنوان التطبيق
|
15 |
st.title("Text Classification App")
|
@@ -20,9 +13,14 @@ text = st.text_area("Enter your text here:")
|
|
20 |
# زر التصنيف
|
21 |
if st.button("Classify"):
|
22 |
if text:
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
27 |
else:
|
28 |
st.warning("Please enter some text!")
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# تحميل النموذج
|
5 |
+
classifier = pipeline("zero-shot-classification", model="joeddav/xlm-roberta-large-xnli")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# عنوان التطبيق
|
8 |
st.title("Text Classification App")
|
|
|
13 |
# زر التصنيف
|
14 |
if st.button("Classify"):
|
15 |
if text:
|
16 |
+
# تحديد الفئات التي تريد تصنيف النص إليها
|
17 |
+
categories = ["shopping", "gaming", "streaming"]
|
18 |
+
result = classifier(text, categories)
|
19 |
+
|
20 |
+
# الحصول على الفئة الأكثر احتمالاً
|
21 |
+
best_category = result['labels'][0]
|
22 |
+
score = round(result['scores'][0], 2)
|
23 |
+
|
24 |
+
st.write(f"Classification Result: {best_category} (Confidence: {score})")
|
25 |
else:
|
26 |
st.warning("Please enter some text!")
|