Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # تحميل النموذج مرة واحدة عند بدء التشغيل | |
| sentiment_pipeline = pipeline( | |
| "sentiment-analysis", | |
| model="CAMeL-Lab/bert-base-arabic-camelbert-da-sentiment" | |
| ) | |
| def analyze(text): | |
| result = sentiment_pipeline(text) | |
| # استخراج التصنيف فقط (positive, negative, neutral) | |
| return result[0]['label'] | |
| # إنشاء الواجهة | |
| iface = gr.Interface( | |
| fn=analyze, | |
| inputs=gr.Textbox(lines=2, placeholder="اكتب النص هنا..."), | |
| outputs="text", | |
| title="تحليل المشاعر العربية", | |
| description="نموذج لتحليل ما إذا كان النص إيجابيًا، سلبيًا، أم محايدًا.", | |
| # --- !! هذا هو السطر الجديد والمهم !! --- | |
| api_name="predict" | |
| # ----------------------------------------- | |
| ) | |
| iface.launch() | |