File size: 976 Bytes
33dbef6
29e4959
 
 
33dbef6
 
 
 
 
 
 
 
 
29e4959
f936c34
9d3ef8a
 
 
 
 
 
29e4959
33dbef6
 
29e4959
8ac658c
f936c34
33dbef6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import streamlit as st  #Web App
from transformers import pipeline
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification


#title
st.title("Sentiment Analysis")


def analyze(input, model):
    return "This is a sample output"

#text insert
input = st.text_area("insert text to be analyzed", value="Nice to see you today.", height=None, max_chars=None, key=None, help=None, on_change=None, args=None, kwargs=None, placeholder=None, disabled=False, label_visibility="visible")
model_name = st.text_input("choose a transformer model (nothing for default)", value="")
if model_name:
    model = TFAutoModelForSequenceClassification.from_pretrained(model_name)
    tokenizer = AutoTokenizer.from_pretrained(model_name)
    classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
else:
    classifier = pipeline('sentiment-analysis')


if st.button('Analyze'):
    st.write(classifier(input))
else:
    st.write('Excited to analyze!')