Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Initialize summarization pipeline
|
| 5 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 6 |
+
|
| 7 |
+
st.title("Text Summarization App")
|
| 8 |
+
st.write("Summarize long articles or texts quickly!")
|
| 9 |
+
|
| 10 |
+
text = st.text_area("Enter text to summarize:", placeholder="Paste your text here...")
|
| 11 |
+
max_length = st.slider("Select maximum summary length:", 50, 300, 100)
|
| 12 |
+
|
| 13 |
+
if st.button("Summarize"):
|
| 14 |
+
if not text.strip():
|
| 15 |
+
st.error("Please provide some text to summarize.")
|
| 16 |
+
else:
|
| 17 |
+
with st.spinner("Generating summary..."):
|
| 18 |
+
summary = summarizer(text, max_length=max_length, min_length=25, do_sample=False)
|
| 19 |
+
st.subheader("Summary:")
|
| 20 |
+
st.write(summary[0]["summary_text"])
|