KEYWORD / app.py
Mohzen321's picture
Create app.py
d436730 verified
raw
history blame
682 Bytes
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()