Spaces:
Runtime error
Runtime error
File size: 654 Bytes
4eaa873 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from optimum.onnxruntime import ORTModelForSeq2SeqLM
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("icon-it-tdtu/mt-en-vi-optimum")
model = ORTModelForSeq2SeqLM.from_pretrained("icon-it-tdtu/mt-en-vi-optimum")
def translate(text):
inputs = tokenizer(text, return_tensors='pt')
outputs = model.generate(**inputs)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
return result
iface = gr.Interface(
fn=translate,
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter English text to translate..."),
outputs="text",
theme="huggingface"
)
iface.launch() |