import streamlit as st from transformers import pipeline, set_seed def generate_summary(text): # Load the summarization model summarizer = pipeline("summarization", model="t5-base", max_length=1024, min_length=40) # Set a random seed for reproducibility set_seed(1) # Generate summary summary = summarizer(text, num_beams=4, no_repeat_ngram_size=2, length_penalty=2.0, early_stopping=True)[0]['summary_text'] return summary def main(): # Set the app title st.title("Text Summarizer") # Create a text box for user input input_text = st.text_area("Enter text to summarize", "") # Create a button to generate the summary if st.button("Summarize"): # Generate summary based on user input if input_text: summary = generate_summary(input_text) st.write(summary) else: st.warning("Please enter some text to summarize.") if __name__ == "__main__": main()