Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load summarization pipeline
|
| 5 |
+
@st.cache_resource
|
| 6 |
+
def load_summarizer():
|
| 7 |
+
return pipeline("summarization", model="facebook/bart-large-cnn")
|
| 8 |
+
|
| 9 |
+
summarizer = load_summarizer()
|
| 10 |
+
|
| 11 |
+
# Streamlit UI
|
| 12 |
+
st.set_page_config(page_title="Text Summarizer", page_icon="📝", layout="centered")
|
| 13 |
+
st.title("📝 Text Summarizer")
|
| 14 |
+
|
| 15 |
+
# Input text
|
| 16 |
+
text = st.text_area("Enter the text you want to summarize:", height=250)
|
| 17 |
+
|
| 18 |
+
# Summary button
|
| 19 |
+
if st.button("Summarize"):
|
| 20 |
+
if text.strip():
|
| 21 |
+
with st.spinner("Generating summary..."):
|
| 22 |
+
summary = summarizer(text, max_length=150, min_length=40, do_sample=False)
|
| 23 |
+
st.subheader("Summary")
|
| 24 |
+
st.success(summary[0]['summary_text'])
|
| 25 |
+
else:
|
| 26 |
+
st.warning("Please enter some text to summarize.")
|