Spaces:
Runtime error
Runtime error
# Libraries | |
import streamlit as st | |
import tensorflow as tf | |
from transformers import pipeline | |
# Milestone 2 | |
# select a pretrained model | |
sentiment_pipeline = pipeline("sentiment-analysis", model = "siebert/sentiment-roberta-large-english") | |
# intro | |
st.title("Sentiment Analysis App") | |
st.write("Enter some text and I'll predict its sentiment!") | |
# add a text input box | |
text_input = st.text_input("Enter your text here:", value = "The weather is nice today.") | |
# run the model when the user clicks submit | |
if st.button("Submit"): | |
# get result | |
sentiment = sentiment_pipeline(text_input) | |
# split into sentiment and score | |
sen = sentiment[0]['label'] | |
score = round(sentiment[0]['score'], 4) | |
# display the prediction | |
st.write(f"Sentiment: {sen} , Confidence Score: {score}") |