File size: 917 Bytes
5de8802
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from nllb import translation, NLLB_EXAMPLES
from flores200_codes import flores_codes

lang_codes = list(flores_codes.keys())

nllb_translate = gr.Interface(
    fn=translation,
    inputs=[
        gr.Dropdown(
            ["nllb-1.3B", "nllb-distilled-1.3B", "nllb-3.3B"],
            label="Model",
            value="nllb-distilled-1.3B",
        ),
        gr.Dropdown(
            lang_codes,
            label="Source language",
            value="English",
        ),
        gr.Dropdown(
            lang_codes,
            label="Target language",
            value="Shan",
        ),
        gr.Textbox(lines=5, label="Input text"),
    ],
    outputs="json",
    examples=NLLB_EXAMPLES,
    title="NLLB Translation Demo",
    description="Translate text from one language to another.",
    allow_flagging="never",
)

with gr.Blocks() as demo:
    nllb_translate.render()

demo.launch()