Spaces:
Configuration error
Configuration error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load summarizer model
|
| 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.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 |
+
if input_text:
|
| 19 |
+
with st.spinner("Summarizing..."):
|
| 20 |
+
summary = summarizer(input_text, max_length=150, min_length=40, do_sample=False)
|
| 21 |
+
st.subheader("Summary:")
|
| 22 |
+
st.success(summary[0]['summary_text'])
|
| 23 |
+
else:
|
| 24 |
+
st.warning("Please enter some text.")
|