File size: 1,148 Bytes
95a5ee1
 
 
14b1706
95a5ee1
52bba6a
 
 
 
95a5ee1
14b1706
 
95a5ee1
5576ab1
266a47d
95a5ee1
 
 
 
 
 
 
 
 
 
 
 
14b1706
 
 
 
 
 
 
 
 
 
 
 
266a47d
 
78d5868
 
 
 
14b1706
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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()