Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,17 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
def load_summarizer():
|
| 7 |
-
return pipeline("summarization", model="facebook/bart-large-cnn")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
st.title("📚 Text Summarizer App")
|
| 13 |
-
st.markdown("Enter or paste long text below. The app will summarize it for you.")
|
| 14 |
-
|
| 15 |
-
input_text = st.text_area("Enter text to summarize", height=300)
|
| 16 |
|
|
|
|
| 17 |
if st.button("Summarize"):
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
else:
|
| 24 |
-
st.warning("Please enter some text.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Set page title
|
| 5 |
+
st.set_page_config(page_title="Text Summarizer", layout="centered")
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Title and input
|
| 8 |
+
st.title("📝 Text Summarizer using BART")
|
| 9 |
+
text = st.text_area("Enter the text you want to summarize:", height=300)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# When button clicked
|
| 12 |
if st.button("Summarize"):
|
| 13 |
+
with st.spinner("Generating summary..."):
|
| 14 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 15 |
+
summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
|
| 16 |
+
st.success("Summary:")
|
| 17 |
+
st.write(summary[0]['summary_text'])
|
|
|
|
|
|