Ahsen Khaliq commited on
Commit
db48d28
β€’
1 Parent(s): e315ba0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -7,7 +7,27 @@ description = "Gradio Demo for MarianMT. To use it, simply add your text, or cli
7
  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>"
8
 
9
  examples = [
10
- ['ζˆ‘ε«ζ²ƒε°”ε€«ε†ˆοΌŒζˆ‘δ½εœ¨ζŸζž—γ€‚']
11
  ]
12
 
13
- gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-zh-en", inputs=gr.inputs.Textbox(lines=5, label="Input Text"),title=title,description=description,article=article, examples=examples).launch(enable_queue=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  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>"
8
 
9
  examples = [
10
+ ['ζˆ‘ε«ζ²ƒε°”ε€«ε†ˆοΌŒζˆ‘δ½εœ¨ζŸζž—γ€‚',"opus-mt-zh-en"]
11
  ]
12
 
13
+ io1 = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-zh-en")
14
+
15
+ io2 = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-en-de")
16
+
17
+ def inference(text, model):
18
+ if model == "opus-mt-zh-en":
19
+ outtext = io1(text)
20
+ else:
21
+ outtext = io2(text)
22
+ return outtext
23
+
24
+
25
+ gr.Interface(
26
+ inference,
27
+ [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")
28
+ ],
29
+ gr.outputs.Textbox(label="Output"),
30
+ examples=examples,
31
+ article=article,
32
+ title=title,
33
+ description=description).launch(enable_queue=True, cache_examples=True)