# import necessary libraries import streamlit as st from transformers import BartForConditionalGeneration, BartTokenizer # Load BART model and tokenizer model_name = "facebook/bart-large-cnn" model = BartForConditionalGeneration.from_pretrained(model_name) tokenizer = BartTokenizer.from_pretrained(model_name) # Streamlit app st.title("ANavya Text Summarizer") # Create a text input box text_input = st.text_area("Enter Text Here:") # Function to summarize text def summarize_text(text): input_ids = tokenizer.encode(text, return_tensors="pt", max_length=1024, truncation=True) summary_ids = model.generate(input_ids, max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True) summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True) return summary # Create a submit button if st.button("Submit", key="ANavya"): if text_input: st.subheader("Summary:") summary = summarize_text(text_input) st.write(summary) # Display a footer or additional information st.sidebar.markdown("Created by [Team Anavya]")