sm2899 commited on
Commit
9708554
β€’
1 Parent(s): eead5f7

Update sentiment-analyser.py

Browse files
Files changed (1) hide show
  1. sentiment-analyser.py +3 -2
sentiment-analyser.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- from transformers import pipeline
3
 
4
  st.title('Sentiment Analyser App')
5
  st.write('Welcome to my sentiment analysis app!')
@@ -14,7 +14,8 @@ def classification(user_input, type):
14
  if type=="sentiment-analysis":
15
  classifier = pipeline("sentiment-analysis")
16
  elif type=="twitter-xlm-roberta-base-sentiment":
17
- classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-xlm-roberta-base-sentiment", tokenizer="cardiffnlp/twitter-xlm-roberta-base-sentiment")
 
18
  result = classifier(user_input)[0]
19
  return result
20
 
 
1
  import streamlit as st
2
+ from transformers import pipeline, AutoTokenizer
3
 
4
  st.title('Sentiment Analyser App')
5
  st.write('Welcome to my sentiment analysis app!')
 
14
  if type=="sentiment-analysis":
15
  classifier = pipeline("sentiment-analysis")
16
  elif type=="twitter-xlm-roberta-base-sentiment":
17
+ tokenizer=AutoTokenizer.from_pretrained(β€œcardiffnlp/twitter-xlm-roberta-base-sentiment”, use_fast=False)
18
+ classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-xlm-roberta-base-sentiment", tokenizer)
19
  result = classifier(user_input)[0]
20
  return result
21