import streamlit as st from transformers import AutoTokenizer, AutoModelForSeq2SeqLM # Load the model and tokenizer from Hugging Face Model Hub model_name = "ASaboor/Saboors_Bart_samsum" # Ensure this is correct tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSeq2SeqLM.from_pretrained(model_name) # Streamlit App st.title("Summarization App") st.write("This app uses a fine-tuned model to summarize text.") # Text input text = st.text_area("Enter text to summarize") # Summarize button if st.button("Summarize"): inputs = tokenizer.encode("summarize: " + text, return_tensors="pt", max_length=512, truncation=True) summary_ids = model.generate(inputs, 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) st.write("Summary:") st.write(summary)