Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
import tensorflow as tf
|
4 |
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
|
|
|
5 |
|
|
|
|
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
# # Load pre-trained model and tokenizer
|
11 |
-
nlp = pipeline("text-classification", model="cardiffnlp/twitter-xlm-roberta-base-sentiment")
|
12 |
|
13 |
# Define function to analyze sentiment
|
14 |
def analyze_sentiment(text):
|
|
|
1 |
import streamlit as st
|
2 |
+
|
3 |
import tensorflow as tf
|
4 |
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
|
5 |
+
from transformers import XLMRobertaTokenizer, AutoModelForSequenceClassification, pipeline
|
6 |
|
7 |
+
# Load tokenizer and model
|
8 |
+
tokenizer = XLMRobertaTokenizer.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment")
|
9 |
+
model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment")
|
10 |
|
11 |
+
# Define pipeline explicitly
|
12 |
+
nlp = pipeline("text-classification", model=model, tokenizer=tokenizer)
|
|
|
|
|
|
|
13 |
|
14 |
# Define function to analyze sentiment
|
15 |
def analyze_sentiment(text):
|