Spaces:
Sleeping
Sleeping
File size: 748 Bytes
27e9654 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Load the model and tokenizer from Hugging Face Model Hub
tokenizer = AutoTokenizer.from_pretrained("zeyadusf/FlanT5Summarization-samsum")
model = AutoModelForSeq2SeqLM.from_pretrained("zeyadusf/FlanT5Summarization-samsum")
def summarize(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True)
summary_ids = model.generate(inputs.input_ids, max_length=512, min_length=64, length_penalty=2.0, num_beams=4, early_stopping=True)
return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
# Define the Gradio interface
iface = gr.Interface(fn=summarize, inputs="text", outputs="text", title="Summarization with PEFT")
iface.launch()
|