Text-Summarizer / app.py
muqeet1234's picture
Update app.py
bead53b verified
import streamlit as st
from transformers import pipeline
# Title and description
st.title("Text Summarizer")
st.markdown("Summarize long paragraphs using the Hugging Face `facebook/bart-large-cnn` model.")
# Load the summarization pipeline
@st.cache_resource
def load_summarizer():
return pipeline("summarization", model="facebook/bart-large-cnn")
summarizer = load_summarizer()
# Input area for the long text
user_input = st.text_area("Enter text to summarize:", placeholder="Paste a long paragraph here...", height=200)
# Summarize button
if st.button("Summarize"):
if user_input.strip():
with st.spinner("Summarizing text..."):
# Perform summarization
summary = summarizer(user_input, max_length=130, min_length=30, do_sample=False)
summarized_text = summary[0]["summary_text"]
# Display the summarized text
st.markdown("### Summarized Text:")
st.write(summarized_text)
else:
st.warning("Please enter some text to summarize.")
# Footer
st.markdown("---")
st.markdown("Powered by [Hugging Face Transformers](https://huggingface.co/transformers/) and Streamlit.")