Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
print ("Loading translator...") | |
model_name = "Helsinki-NLP/opus-mt-en-zh" | |
# tokenizer = AutoTokenizer.from_pretrained(model_name) | |
translator = pipeline(task="translation_en_to_zh", model=model_name) | |
def translate(text): | |
return translator(text)[0]['translation_text'] | |
gr.Interface(fn=translate, inputs="text", outputs="text").launch() | |