Layan22 commited on
Commit
95821bd
·
verified ·
1 Parent(s): 42984a2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
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(
16
+ fn=predict_sentiment,
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