feaae commited on
Commit
73568e2
·
1 Parent(s): fc9619f

initial commit

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import pipeline
4
+
5
+ pipe = pipeline("translation_en_to_zh", model='facebook/m2m100_418M')
6
+
7
+
8
+ def translate(text):
9
+ return pipe(text)[0]["translation_text"]
10
+
11
+ with gr.Blocks() as demo:
12
+ with gr.Row():
13
+ with gr.Column():
14
+ english = gr.Textbox(label="English text")
15
+ translate_btn = gr.Button(value="Translate")
16
+ with gr.Column():
17
+ chinese = gr.Textbox(label="Chinese Text")
18
+
19
+ translate_btn.click(translate, inputs=english, outputs=chinese, api_name="translate-to-chinese")
20
+ examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
21
+ inputs=[english])
22
+
23
+ demo.launch()