import gradio as gr import numpy as np from huggingface_hub import hf_hub_download from transformers import pipeline REPO_ID_NLLB = "facebook/nllb-200-distilled-600M" REPO_ID_MARIANNMT_en = "mbarnig/MarianNMT-tatoeba-en-lb" REPO_ID_MARIANNMT_lb = "mbarnig/MarianNMT-tatoeba-lb-en" REPO_ID_T5MT5 = "mbarnig/T5-mt5-tatoeba-en-lb" translator = pipeline("translation", model=REPO_ID_NLLB) my_title = "🇫🇷 Mir iwwersetzen vun an op Lëtzebuergesch ! 🇬🇧" my_description = "English-Luxembourgish machine translation (MT) demo based on 3 transformer models: NLLB, MarianNMT & T5/mt5." my_article = "abc" TRANSLATION_MODELS = [ "NLLB", "MarianNMT", "T5/mt5" ] TRANSLATION_DIRECTION = [ "en -> lb", "lb -> en" ] EXAMPLE = "..." my_input = gr.Textbox(label="Input") my_output = gr.Textbox(label="Translation") def iwwersetz(source_text): translation = translator(source_text) return translation demo=gr.Interface( fn=iwwersetz, inputs=my_input, outputs=my_output, title=my_title, description=my_description, article=my_article, examples=EXAMPLE, allow_flagging=False) demo.launch()