|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
sentiment_pipeline = pipeline("sentiment-analysis") |
|
|
|
st.title("Sentiment Analysis") |
|
st.write("Welcome sentiment analysis Spaces' built using Streamlit and Hugging Face's Transformers library. The application allows users to input a sentence and receive a real-time sentiment analysis result, along with a confidence score.") |
|
|
|
user_input = st.text_input("Write a sentence please:") |
|
if user_input: |
|
result = sentiment_pipeline(user_input) |
|
sentiment = result[0]["label"] |
|
confidence = result[0]["score"] |
|
|
|
st.write(f"Sentiment: {sentiment}") |
|
st.write(f"Confidence: {confidence:.2f}") |
|
|