File size: 777 Bytes
56783fd fe0f8b9 56783fd fe0f8b9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
from transformers import pipeline
examples = [
"Where is she?",
"I would like to test this new model for machine translation",
"All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience..."
]
generator = pipeline("text2text-generation", model="jo-valer/nllb-multi")
def translate(text):
return generator(text)[0]["generated_text"]
interface = gr.Interface(
fn=translate,
inputs=gr.Textbox(lines=3, placeholder="Enter English/Italian Text Here...", label="Input text"),
outputs=gr.Textbox(label="Ladin Translation", show_copy_button=True),
title="Ladin Machine Translation",
allow_flagging="never",
examples=examples,
cache_examples=True,
)
interface.launch()
|