Chijioke commited on
Commit
28820a2
1 Parent(s): 016da0a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from transformers import pipeline
4
+
5
+ pipe = pipeline("translation", model="t5-base")
6
+
7
+ def translate(text):
8
+ return pipe(text)[0]["translation_text"]
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
+ german = gr.Textbox(label="German text")
17
+
18
+ translate_btn.click(translate, inputs=english, outputs=german)
19
+ examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
20
+ inputs=[english])
21
+
22
+ demo.launch()