File size: 935 Bytes
d1136a7
 
 
 
010b53b
d1136a7
8966170
 
 
d1136a7
010b53b
 
8966170
d1136a7
 
 
 
 
 
010b53b
ee154c9
 
010b53b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

deployed_repo_id = "maryaa4/my-arabic-sentiment-model"
loaded_sentiment_pipeline = pipeline('sentiment-analysis', model=deployed_repo_id, trust_remote_code=True)

def predict_sentiment(text):
    if not text:
        return "Please enter some text for sentiment analysis."
    result = loaded_sentiment_pipeline(text)
    label = result[0]['label']
    score = result[0]['score']
    return f"Sentiment: {label.capitalize()}, Confidence: {score:.4f}"

iface = gr.Interface(
    fn=predict_sentiment,
    inputs=gr.Textbox(lines=5, placeholder="أدخل النص العربي هنا..."),
    outputs="text",
    title="Arabic Sentiment Analysis",
    description=f"A sentiment analysis model for Arabic text, deployed from maryaa4/my-arabic-sentiment-model. Enter Arabic text and get the predicted sentiment."
)

iface.launch(share=True) # share=True for a temporary public link