felixz's picture
Update app.py
dbc8937
raw
history blame
555 Bytes
import gradio as gr
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-large")
input_text = "translate English to German: How old are you?"
def greet(input_text):
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
outputs = model.generate(input_ids, max_length=40)
return tokenizer.decode(outputs[0])
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()