File size: 682 Bytes
cf8314e
 
 
 
 
 
 
 
 
d436730
cf8314e
 
d436730
 
 
 
 
 
 
 
cf8314e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import pipeline

# تحميل النموذج
classifier = pipeline("text-classification", model="distilbert-base-uncased")

# دالة لتصنيف النص
def classify_text(text):
    result = classifier(text)
    return {label: round(score, 2) for label, score in zip(result[0]['labels'], result[0]['scores'])}

# إنشاء واجهة مستخدم
iface = gr.Interface(
    fn=classify_text,
    inputs=gr.Textbox(lines=5, placeholder="Enter text here..."),
    outputs="json",
    title="Text Classification App",
    description="This app classifies your text into predefined categories and shows the confidence scores."
)

iface.launch()