Spaces:
Sleeping
Sleeping
File size: 805 Bytes
e971d78 724e27c e971d78 724e27c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import streamlit as st
from transformers import pipeline
# Load model
@st.cache_resource
def load_model():
return pipeline(
"sentiment-analysis",
model="w11wo/indonesian-roberta-base-sentiment-classifier"
)
classifier = load_model()
# UI
st.title("Sentiment Analysis Bahasa Indonesia 🇮🇩")
text = st.text_area("Masukkan teks:")
if st.button("Analisis"):
if text.strip() != "":
result = classifier(text)
label = result[0]['label']
score = result[0]['score']
st.write(f"Sentimen: {label}")
st.write(f"Confidence: {score:.2f}")
if label.lower() == "positive":
st.success("Positif")
elif label.lower() == "negative":
st.error("Negatif")
else:
st.warning("Masukkan teks dulu!") |