Vineedhar commited on
Commit
0a0cca6
·
verified ·
1 Parent(s): 1036d50

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,14 +1,15 @@
1
  import streamlit as st
2
- from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
3
  import tensorflow as tf
4
  tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
 
5
 
 
 
 
6
 
7
- # tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment")
8
- # model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment")
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):