|
|
import streamlit as st |
|
|
from transformers import pipeline |
|
|
|
|
|
|
|
|
@st.cache_resource |
|
|
def load_model(): |
|
|
return pipeline("sentiment-analysis") |
|
|
|
|
|
model = load_model() |
|
|
|
|
|
|
|
|
st.title("🧠 Sentiment Analysis App") |
|
|
st.write("Type a sentence and find out if it’s Positive or Negative!") |
|
|
|
|
|
user_input = st.text_area("Enter your text here 👇") |
|
|
|
|
|
if st.button("Analyze Sentiment"): |
|
|
if user_input.strip(): |
|
|
result = model(user_input)[0] |
|
|
st.success(f"**Label:** {result['label']} | **Score:** {result['score']:.2f}") |
|
|
else: |
|
|
st.warning("Please enter some text!") |
|
|
|