TA_1 / app.py
Dineth98's picture
Update app.py
47ea938
raw
history blame
846 Bytes
import streamlit as st
from transformers import pipeline
def sentiment_funtion(text):
model = pipeline("sentiment-analysis", model="stevhliu/my_awesome_model")
output = model(text)[0]
label = output["label"]
score = output["score"]
return label , score
def main():
user_input = st.text_area("Input Text Here")
if st.button("Sentiment"):
label , score = sentiment_funtion(user_input)
if label == "LABEL_0":
label = "Positive"
postive_score = score
negative_score = 1 - score
else:
label = "Negative"
postive_score = 1 - score
negative_score = score
st.write("Sentiment:")
st.write(label)
st.write(postive_score)
st.write(negative_score)
if __name__ == "__main__":
main()