File size: 988 Bytes
594f70f
f9655e5
 
594f70f
f9655e5
 
594f70f
 
f9655e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7f3a0e6
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

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")