Spaces:
Sleeping
Sleeping
pakmandesign
commited on
Commit
•
541f702
1
Parent(s):
b79476c
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
# build the rranslation pipeline with the pre-trained model
|
4 |
+
pipe = pipeline("translation", model="t5-base")
|
5 |
+
|
6 |
+
def translate(text):
|
7 |
+
return pipe(text)[0]["translation_text"]
|
8 |
+
|
9 |
+
with gr.Blocks() as demo:
|
10 |
+
with gr.Row():
|
11 |
+
with gr.Column():
|
12 |
+
english = gr.Textbox(label="English text")
|
13 |
+
translate_btn = gr.Button(value="Translate")
|
14 |
+
with gr.Column():
|
15 |
+
german = gr.Textbox(label="German Text")
|
16 |
+
|
17 |
+
translate_btn.click(translate, inputs=english, outputs=german, api_name="translate-to-german")
|
18 |
+
example = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."], inputs=[english])
|
19 |
+
|
20 |
+
demo.launch()
|