Jeffrey Rathgeber Jr commited on
Commit
47ef74f
·
unverified ·
1 Parent(s): c704d04

pipelinetest

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -1,8 +1,16 @@
1
  import streamlit as st
2
- import numpy as np
 
3
 
4
- st.text_input("Input Text Here:", "I really like the color of your car!")
5
 
6
- option = st.selectbox('What pre-trained model would you like for your sentiment analysis?',('TensorFlow', 'PyTorch', 'JAX'))
 
 
7
 
8
  st.write('You selected:', option)
 
 
 
 
 
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
+ # import numpy as np
4
 
5
+ classifier = pipeline(task="sentiment-analysis")
6
 
7
+ textIn = st.text_input("Input Text Here:", "I really like the color of your car!")
8
+
9
+ option = st.selectbox('Which pre-trained model would you like for your sentiment analysis?',('TensorFlow', 'PyTorch', 'JAX'))
10
 
11
  st.write('You selected:', option)
12
+
13
+ # pipeline
14
+ preds = classifier(textIn)
15
+ preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in preds]
16
+ st.write('Input text is ', preds[0]['label'], ' with a confidence of ', preds[0]['score'])