Javedalam commited on
Commit
44f0758
1 Parent(s): da32fd2

Create app.py

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