import gradio as gr | |
from transformers import pipeline | |
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-zh") | |
def predict(text): | |
return pipe(text)[0]["translation_text"] | |
title = "English to Chinese Translation" | |
iface = gr.Interface( | |
fn=predict, | |
inputs=[gr.Textbox(label="text", lines=3)], | |
outputs='text', | |
title=title, | |
) | |
iface.launch() |