DAM / app.py
Kari's picture
Add application file
7b83b25
raw
history blame
481 Bytes
# Helsinki-NLP/opus-mt-zh-en
import gradio as gr
from transformers import pipeline
import os
translator = pipeline("translation", model=os.path.join(os.getcwd(),"test-ml-trained"), max_time=5)
def en2zh(EnNames):
pres=[]
for name in EnNames:
pre = translator(str(name).replace('_',' '), )[0]["translation_text"]
pres.append(pre)
print(name,pre)
return pres
interface = gr.Interface(fn=en2zh, inputs="list", outputs="label")
interface.launch()