Mohzen321 commited on
Commit
dd537e9
·
verified ·
1 Parent(s): 79938b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -2,7 +2,14 @@ import streamlit as st
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 +20,9 @@ text = st.text_area("Enter your text here:")
13
  # زر التصنيف
14
  if st.button("Classify"):
15
  if text:
16
- # تحديد الفئات التي تريد تصنيف النص إليها
17
- categories = ["شوبينج", "جيمينج", "تكنولوجيا", "رياضة", "صحة"]
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!")
 
2
  from transformers import pipeline
3
 
4
  # تحميل النموذج
5
+ classifier = pipeline("text-classification", model="distilbert-base-uncased")
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
  # زر التصنيف
21
  if st.button("Classify"):
22
  if text:
23
+ result = classifier(text)
24
+ label = result[0]['label']
25
+ mapped_label = labels.get(label, "Unknown")
26
+ st.write(f"Classification Result: {mapped_label}")
 
 
 
 
 
27
  else:
28
  st.warning("Please enter some text!")