import gradio as gr from transformers import pipeline pipe = pipeline("translation_en_to_fr", model="t5-base") def translate(text): return pipe(text)[0]['translation_text'] with gr.Blocks() as demo: with gr.Row(): with gr.Column(): english = gr.Textbox(label="English text") translate_btn = gr.Button(value="Translate") with gr.Column(): France = gr.Textbox(label="France text") translate_btn.click(fn=translate, inputs=[english], outputs=[France]) examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."], inputs=[english]) demo.launch(server_name="0.0.0.0", server_port=7860)