from transformers import pipeline import gradio as gr language_translation_ckpt = f"Helsinki-NLP/opus-mt-nl-en" translator = pipeline("translation", model=language_translation_ckpt) def translate_nl_en(text): translation = translator(text) translation = translation[0]['translation_text'] return translation with gr.Blocks() as demo: nl_text = gr.Textbox(label="NL") en_text = gr.Textbox(label="EN") translate_button = gr.Button("Vertaal") translate_button.click(translate_nl_en, inputs=nl_text, outputs=en_text, api_name=translate_nl_en) demo.launch()