File size: 1,061 Bytes
e315ba0
 
 
 
 
 
 
 
 
db48d28
e315ba0
 
db48d28
 
 
 
 
 
 
 
 
 
 
 
 
 
1e44043
 
db48d28
 
 
1e44043
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
import gradio as gr

title = "MarianMT"

description = "Gradio Demo for MarianMT. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."

article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1804.00344' target='_blank'>Marian: Fast Neural Machine Translation in C++</a></p>"

examples = [
    ['ζˆ‘ε«ζ²ƒε°”ε€«ε†ˆοΌŒζˆ‘δ½εœ¨ζŸζž—γ€‚',"opus-mt-zh-en"]
]

io1 = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-zh-en")

io2 = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-en-de")

def inference(text, model):
    if model == "opus-mt-zh-en":
        outtext = io1(text)
    else:
        outtext = io2(text)
    return outtext   
     

gr.Interface(
    inference, 
    [gr.inputs.Textbox(label="Input"),gr.inputs.Dropdown(choices=["opus-mt-zh-en","opus-mt-en-de"], type="value", default="opus-mt-zh-en", label="model")], 
    [gr.outputs.Textbox(label="Output")],
    examples=examples,
    article=article,
    title=title,
    description=description).launch(enable_queue=True)