Commit
·
2c6ad4c
1
Parent(s):
8ecf454
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
-
pip install googletrans==4.0.0rc1
|
| 2 |
import streamlit as st
|
| 3 |
from transformers import pipeline
|
| 4 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 5 |
-
from googletrans import Translator
|
| 6 |
|
| 7 |
# Load the sentiment analysis model from our BERT model
|
| 8 |
classifier = pipeline("text-classification", model = "MarieAngeA13/Sentiment-Analysis-BERT")
|
|
@@ -15,21 +13,11 @@ st.write('Enter some text and we will predict its sentiment!')
|
|
| 15 |
translator = Translator()
|
| 16 |
text_input = st.text_input('Enter text here')
|
| 17 |
|
| 18 |
-
detected_language = translator.detect(text_input).lang
|
| 19 |
-
|
| 20 |
-
if detected_language == 'fr':
|
| 21 |
-
translation = translator.translate(text_input, src='fr', dest='en')
|
| 22 |
-
translated_text = translation.text
|
| 23 |
-
else:
|
| 24 |
-
translated_text = text_input
|
| 25 |
-
print(translated_text)
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
# When the user submits text, run the sentiment analysis model on it
|
| 30 |
if st.button('Submit'):
|
| 31 |
# Predict the sentiment of the text using our own BERT model
|
| 32 |
-
output = classifier(
|
| 33 |
|
| 34 |
best_prediction = output[0]
|
| 35 |
sentiment = best_prediction['label']
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
|
|
|
| 4 |
|
| 5 |
# Load the sentiment analysis model from our BERT model
|
| 6 |
classifier = pipeline("text-classification", model = "MarieAngeA13/Sentiment-Analysis-BERT")
|
|
|
|
| 13 |
translator = Translator()
|
| 14 |
text_input = st.text_input('Enter text here')
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# When the user submits text, run the sentiment analysis model on it
|
| 18 |
if st.button('Submit'):
|
| 19 |
# Predict the sentiment of the text using our own BERT model
|
| 20 |
+
output = classifier(text_input)
|
| 21 |
|
| 22 |
best_prediction = output[0]
|
| 23 |
sentiment = best_prediction['label']
|