Spaces:
Sleeping
Sleeping
File size: 1,176 Bytes
1d5d9de cf3659c 1d5d9de cf3659c 1d5d9de cf3659c 1d5d9de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import streamlit as st
from transformers import pipeline
def main():
st.title("Text Summarization")
# Initialize the summarizer pipeline
summarizer = pipeline(
task="summarization",
model="facebook/bart-large-cnn", # Using a different model for better summarization
min_length=50, # Increased minimum length to capture more details
max_length=150, # Adjusted max length to allow for more detailed summaries
truncation=True,
)
# User input
input_text = st.text_area("Enter the text you want to summarize:", height=200)
# Summarize button
if st.button("Summarize"):
if input_text:
# Generate the summary
output = summarizer(input_text, max_length=150, min_length=50, do_sample=False)
summary = output[0]['summary_text']
# Display the summary as bullet points
st.subheader("Summary:")
bullet_points = summary.split(". ")
for point in bullet_points:
st.write(f"- {point.strip()}")
else:
st.warning("Please enter text to summarize.")
if __name__ == "__main__":
main()
|