Create app.py
Browse files
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])
|