Spaces:
Runtime error
Runtime error
File size: 395 Bytes
8aaaea4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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()
|