File size: 636 Bytes
341b746 c3db1be 341b746 c3db1be |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import gradio as gr
from transformers import T5Tokenizer, T5ForConditionalGeneration
def generate_text(input_text):
# Load pre-trained model and tokenizer
model_name = 'kurry/t5_small_finetuned'
model = T5ForConditionalGeneration.from_pretrained(model_name)
tokenizer = T5Tokenizer.from_pretrained(model_name)
# Generate summary
inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", truncation=True)
outputs = model.generate(inputs)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
iface = gr.Interface(fn=generate_text, inputs='text', outputs='text')
iface.launch()
|