VeyVey commited on
Commit
c25095a
1 Parent(s): 927898c

Create app.py

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