Spaces:
Sleeping
Sleeping
File size: 913 Bytes
338bfdb 3c0e007 338bfdb 02f15d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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()
|