Spaces:
Sleeping
Sleeping
Update app.py
Browse filesUpdated the Model and the analysis output
app.py
CHANGED
@@ -2,12 +2,18 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Load pre-trained model and tokenizer from Hugging Face
|
5 |
-
model_name = "aubmindlab/bert-base-arabertv02-twitter"
|
6 |
-
|
|
|
7 |
|
8 |
def analyze_sentiment(text):
|
9 |
-
result = sentiment_analysis(text)
|
10 |
-
return result
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Define Gradio interface
|
13 |
iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text", title="Arabic Sentiment Analysis")
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Load pre-trained model and tokenizer from Hugging Face
|
5 |
+
#model_name = "aubmindlab/bert-base-arabertv02-twitter"
|
6 |
+
model_name = "CAMeL-Lab/bert-base-arabic-camelbert-msa-sentiment"
|
7 |
+
sentiment_analysis = pipeline("sentiment-analysis", model=model_name, tokenizer="CAMeL-Lab/bert-base-arabic-camelbert-msa-sentiment")
|
8 |
|
9 |
def analyze_sentiment(text):
|
10 |
+
#result = sentiment_analysis(text)
|
11 |
+
#return result
|
12 |
+
result = sentiment_analyzer(text)[0]
|
13 |
+
return jsonify({
|
14 |
+
"sentiment": result['label'],
|
15 |
+
"confidence": result['score']
|
16 |
+
})
|
17 |
|
18 |
# Define Gradio interface
|
19 |
iface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text", title="Arabic Sentiment Analysis")
|