Spaces:
Runtime error
Runtime error
File size: 882 Bytes
45737ef 807fa0b 45737ef 807fa0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import streamlit as st
from transformers import pipeline
from transformers import AutoTokenizer, AutoModelForSequenceClassification
models = ["cardiffnlp/twitter-xlm-roberta-base-sentiment", "nlptown/bert-base-multilingual-uncased-sentiment", "Tatyana/rubert-base-cased-sentiment-new"]
st.title('Sentiment Analysis Demo')
st.markdown("Junming Qiu")
with st.form("form"):
selection = st.selectbox('Select Transformer', models)
text = st.text_input('Enter text: ', "I do not like to walk")
submitted = st.form_submit_button('Submit')
if submitted:
model_name = models[models.index(selection)]
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
st.write(classifier(text)) |