Spaces:
Running
Running
Upload with huggingface_hub
Browse files
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.3.1
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
|
2 |
---
|
3 |
+
title: english_translator
|
4 |
+
emoji: 🔥
|
5 |
+
colorFrom: indigo
|
6 |
+
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.3.1
|
9 |
+
|
10 |
app_file: app.py
|
11 |
pinned: false
|
12 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
21 |
+
examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
|
22 |
+
inputs=[english])
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
demo.launch()
|