import streamlit as st from transformers import AutoTokenizer, AutoModelForSeq2SeqLM # Load the tokenizer and model from the Hugging Face Model Hub model_path = 'abdulllah01/mt5-Summarizer-FineTuned' tokenizer = AutoTokenizer.from_pretrained(model_path) model = AutoModelForSeq2SeqLM.from_pretrained(model_path) # Streamlit app st.title("Summarization App") st.write("This app summarizes text using a fine-tuned T5 model.") # User input user_input = st.text_area("Enter text to summarize", "") if st.button("Summarize"): if user_input: inputs = tokenizer.encode("summarize: " + user_input, 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) else: st.write("Please enter some text to summarize.")