first_game / app.py
temii001's picture
Update app.py
1a0cb8e verified
raw
history blame contribute delete
505 Bytes
# app.py
import streamlit as st
from transformers import pipeline
st.title("🤗 Sentiment Detection (Hugging Face Model)")
# Load model once
@st.cache_resource
def load_model():
return pipeline("sentiment-analysis")
model = load_model()
text = st.text_area("Enter text:")
if st.button("Analyze"):
if text.strip():
result = model(text)[0]
st.write(f"**Sentiment:** {result['label']} ({round(result['score']*100, 2)}%)")
else:
st.warning("Please enter some text.")