patloeber commited on
Commit
92c678d
1 Parent(s): 7a7626f

initial commit

Browse files
Files changed (2) hide show
  1. app.py +22 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
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(["I went to the supermarket yesterday.",
20
+ "Helen is a good swimmer."], english)
21
+
22
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ torch
3
+ transformers