Spaces:
Sleeping
Sleeping
File size: 697 Bytes
7a464fd b616807 2ec9ce1 7a464fd |
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 gradio as gr
def greet(name):
return "Hello " + name + "!!"
def translate(input):
from transformers import T5ForConditionalGeneration, T5Tokenizer
model_name = 'jbochi/madlad400-3b-mt'
model = T5ForConditionalGeneration.from_pretrained(model_name, device_map="auto")
tokenizer = T5Tokenizer.from_pretrained(model_name)
text = f"<2en>{input}"
input_ids = tokenizer(text, return_tensors="pt").input_ids.to(model.device)
outputs = model.generate(input_ids=input_ids)
tokenizer.decode(outputs[0], skip_special_tokens=True)
# Eu adoro pizza!
return output
demo = gr.Interface(fn=translate, inputs="text", outputs="text")
demo.launch()
|