wayne0019 commited on
Commit
f68afe9
1 Parent(s): 24656a7

Create test.py

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