Spaces:
Runtime error
Runtime error
Commit
·
e8be44f
1
Parent(s):
b34102e
Update app.py
Browse files
app.py
CHANGED
@@ -1,48 +1,26 @@
|
|
1 |
-
# import sentencepiece
|
2 |
-
|
3 |
-
|
4 |
-
# import streamlit as st
|
5 |
-
# from transformers import pipeline
|
6 |
-
|
7 |
-
# sentiment_analysis = pipeline("sentiment-analysis")
|
8 |
-
# translation = pipeline("translation_en_to_ar", model="anibahug/marian-finetuned-kde4-en-to-ar")
|
9 |
-
|
10 |
-
# text = st.text_input("Enter some text")
|
11 |
-
|
12 |
-
# if text:
|
13 |
-
# result = sentiment_analysis(text)
|
14 |
-
# st.json(result)
|
15 |
-
|
16 |
-
# if text:
|
17 |
-
# result = translation(text)[0]
|
18 |
-
# st.write(f"Translated text: {result['translation_text']}")
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
import streamlit as st
|
25 |
-
from transformers import pipeline
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
# tokenizer = AutoTokenizer.from_pretrained(model_name)
|
30 |
-
# , tokenizer=tokenizer
|
31 |
-
sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
|
32 |
|
33 |
-
|
34 |
-
st.title("Sentiment Analysis App")
|
35 |
|
36 |
-
|
37 |
-
user_input = st.text_input("Enter a sentence:")
|
38 |
|
39 |
-
if
|
40 |
-
|
41 |
-
results = sentiment_analyzer(user_input)
|
42 |
|
43 |
-
# Display sentiment and confidence
|
44 |
sentiment = results[0]['label']
|
45 |
confidence = results[0]['score']
|
46 |
|
47 |
st.write(f"Sentiment: {sentiment}")
|
48 |
-
st.write(f"Confidence: {confidence:.2f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
st.title("Sentiment Analysis And Translation App")
|
5 |
+
text = st.text_input("Enter a sentence:")
|
|
|
|
|
|
|
6 |
|
7 |
+
sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
|
|
|
8 |
|
9 |
+
translation = pipeline("translation_en_to_ar", model="anibahug/marian-finetuned-kde4-en-to-ar")
|
|
|
10 |
|
11 |
+
if text:
|
12 |
+
results = sentiment_analyzer(text)
|
|
|
13 |
|
|
|
14 |
sentiment = results[0]['label']
|
15 |
confidence = results[0]['score']
|
16 |
|
17 |
st.write(f"Sentiment: {sentiment}")
|
18 |
+
st.write(f"Confidence: {confidence:.2f}")
|
19 |
+
|
20 |
+
# if text:
|
21 |
+
# result = sentiment_analysis(text)
|
22 |
+
# st.json(result)
|
23 |
+
|
24 |
+
if text:
|
25 |
+
result = translation(text)[0]
|
26 |
+
st.write(f"Translated text: {result['translation_text']}")
|