Upload Streamlit app for Indonesian summarizer
Browse files- README.md +25 -13
- app.py +43 -0
- requirements.txt +4 -0
README.md
CHANGED
|
@@ -1,13 +1,25 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Indonesian News Summarizer
|
| 2 |
+
|
| 3 |
+
This is a Streamlit web app that summarizes Indonesian news articles using the `cahya/t5-base-indonesian-summarization-cased` model from Hugging Face.
|
| 4 |
+
|
| 5 |
+
## Features
|
| 6 |
+
- Input a news article URL (e.g., from Detik.com)
|
| 7 |
+
- Extracts full article text using `newspaper3k`
|
| 8 |
+
- Summarizes using a fine-tuned T5 model
|
| 9 |
+
|
| 10 |
+
## Setup & Run
|
| 11 |
+
|
| 12 |
+
```bash
|
| 13 |
+
pip install -r requirements.txt
|
| 14 |
+
streamlit run app.py
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
## Deployment on Hugging Face Spaces
|
| 18 |
+
1. Create a new Space (SDK: Streamlit)
|
| 19 |
+
2. Clone the Hugging Face repo
|
| 20 |
+
3. Push this project into the repo
|
| 21 |
+
```bash
|
| 22 |
+
git add .
|
| 23 |
+
git commit -m "Upload summarizer app"
|
| 24 |
+
git push
|
| 25 |
+
```
|
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from newspaper import Article
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
# Load model from Hugging Face
|
| 6 |
+
@st.cache_resource
|
| 7 |
+
def load_summarizer():
|
| 8 |
+
return pipeline(
|
| 9 |
+
"summarization",
|
| 10 |
+
model="cahya/t5-base-indonesian-summarization-cased",
|
| 11 |
+
tokenizer="cahya/t5-base-indonesian-summarization-cased"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
summarizer = load_summarizer()
|
| 15 |
+
|
| 16 |
+
st.title("📰 Indonesian News Summarizer")
|
| 17 |
+
st.write("Enter a URL from an Indonesian news website (e.g. Detik.com)")
|
| 18 |
+
|
| 19 |
+
url = st.text_input("Paste the article URL here:")
|
| 20 |
+
|
| 21 |
+
if st.button("Show Article Text"):
|
| 22 |
+
if url:
|
| 23 |
+
try:
|
| 24 |
+
article = Article(url, language='id')
|
| 25 |
+
article.download()
|
| 26 |
+
article.parse()
|
| 27 |
+
st.subheader("Full Article:")
|
| 28 |
+
st.write(article.text)
|
| 29 |
+
st.session_state.article_text = article.text
|
| 30 |
+
except Exception as e:
|
| 31 |
+
st.error(f"Failed to fetch article: {str(e)}")
|
| 32 |
+
else:
|
| 33 |
+
st.warning("Please input a valid URL.")
|
| 34 |
+
|
| 35 |
+
if st.button("Summarize"):
|
| 36 |
+
if "article_text" in st.session_state:
|
| 37 |
+
with st.spinner("Summarizing..."):
|
| 38 |
+
input_text = "ringkasan: " + st.session_state.article_text
|
| 39 |
+
summary = summarizer(input_text, max_length=150, min_length=40, do_sample=False)
|
| 40 |
+
st.subheader("Summary:")
|
| 41 |
+
st.success(summary[0]['summary_text'])
|
| 42 |
+
else:
|
| 43 |
+
st.warning("No article text found. Please load the article first.")
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
newspaper3k
|
| 3 |
+
transformers
|
| 4 |
+
torch
|