Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,18 +2,14 @@ import gradio as gr
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
deployed_repo_id = "maryaa4/my-arabic-sentiment-model"
|
| 5 |
-
loaded_sentiment_pipeline = pipeline(
|
| 6 |
-
"sentiment-analysis",
|
| 7 |
-
model=deployed_repo_id,
|
| 8 |
-
trust_remote_code=True
|
| 9 |
-
)
|
| 10 |
|
| 11 |
def predict_sentiment(text):
|
| 12 |
if not text:
|
| 13 |
return "Please enter some text for sentiment analysis."
|
| 14 |
result = loaded_sentiment_pipeline(text)
|
| 15 |
-
label = result[0][
|
| 16 |
-
score = result[0][
|
| 17 |
return f"Sentiment: {label.capitalize()}, Confidence: {score:.4f}"
|
| 18 |
|
| 19 |
iface = gr.Interface(
|
|
@@ -21,8 +17,7 @@ iface = gr.Interface(
|
|
| 21 |
inputs=gr.Textbox(lines=5, placeholder="أدخل النص العربي هنا..."),
|
| 22 |
outputs="text",
|
| 23 |
title="Arabic Sentiment Analysis",
|
| 24 |
-
description="A sentiment analysis model for Arabic text, deployed from maryaa4/my-arabic-sentiment-model. Enter Arabic text and get the predicted sentiment."
|
| 25 |
)
|
| 26 |
|
| 27 |
-
|
| 28 |
-
app = iface
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
deployed_repo_id = "maryaa4/my-arabic-sentiment-model"
|
| 5 |
+
loaded_sentiment_pipeline = pipeline('sentiment-analysis', model=deployed_repo_id, trust_remote_code=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def predict_sentiment(text):
|
| 8 |
if not text:
|
| 9 |
return "Please enter some text for sentiment analysis."
|
| 10 |
result = loaded_sentiment_pipeline(text)
|
| 11 |
+
label = result[0]['label']
|
| 12 |
+
score = result[0]['score']
|
| 13 |
return f"Sentiment: {label.capitalize()}, Confidence: {score:.4f}"
|
| 14 |
|
| 15 |
iface = gr.Interface(
|
|
|
|
| 17 |
inputs=gr.Textbox(lines=5, placeholder="أدخل النص العربي هنا..."),
|
| 18 |
outputs="text",
|
| 19 |
title="Arabic Sentiment Analysis",
|
| 20 |
+
description=f"A sentiment analysis model for Arabic text, deployed from maryaa4/my-arabic-sentiment-model. Enter Arabic text and get the predicted sentiment."
|
| 21 |
)
|
| 22 |
|
| 23 |
+
iface.launch(share=True) # share=True for a temporary public link
|
|
|