Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
# تحميل النموذج | |
classifier = pipeline("zero-shot-classification", model="cross-encoder/nli-distilroberta-base") | |
# عنوان التطبيق | |
st.title("Text Classification App") | |
# إدخال النص | |
text = st.text_area("Enter your text here:") | |
# زر التصنيف | |
if st.button("Classify"): | |
if text: | |
# تحديد الفئات التي تريد تصنيف النص إليها | |
categories = ["shopping", "gaming", "streaming"] | |
result = classifier(text, categories) | |
# الحصول على الفئة الأكثر احتمالاً | |
best_category = result['labels'][0] | |
score = round(result['scores'][0], 2) | |
st.write(f"Classification Result: {best_category} (Confidence: {score})") | |
else: | |
st.warning("Please enter some text!") |