Spaces:
Running
Running
Download src/streamlit_app.py from Eleanorabby/Sentiment_Indonesia: direct link, hf CLI and curl.
- Browser
- Download file 805 Bytes
-
https://huggingface.co/spaces/Eleanorabby/Sentiment_Indonesia/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/Eleanorabby/Sentiment_Indonesia/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/Eleanorabby/Sentiment_Indonesia/resolve/main/src/streamlit_app.py
805 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| # Load model | |
| 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!") |