junming-qiu commited on
Commit
807fa0b
1 Parent(s): 46d010b

streamlit v1

Browse files
Files changed (2) hide show
  1. app.py +20 -2
  2. init.bash +4 -1
app.py CHANGED
@@ -1,4 +1,22 @@
1
  import streamlit as st
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
 
5
+
6
+ models = ["cardiffnlp/twitter-xlm-roberta-base-sentiment", "nlptown/bert-base-multilingual-uncased-sentiment", "Tatyana/rubert-base-cased-sentiment-new"]
7
+
8
+
9
+
10
+ st.title('Sentiment Analysis Demo')
11
+ st.markdown("Junming Qiu")
12
+ with st.form("form"):
13
+ selection = st.selectbox('Select Transformer', models)
14
+ text = st.text_input('Enter text: ', "I do not like to walk")
15
+ submitted = st.form_submit_button('Submit')
16
+
17
+ if submitted:
18
+ model_name = models[models.index(selection)]
19
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
20
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
21
+ classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
22
+ st.write(classifier(text))
init.bash CHANGED
@@ -1,3 +1,6 @@
1
  sudo apt update
2
  sudo apt install python3-pip
3
- pip install streamlit
 
 
 
 
1
  sudo apt update
2
  sudo apt install python3-pip
3
+ pip install streamlit
4
+ pip install transformers datasets
5
+ pip install torch
6
+ pip install sentencepiece