Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,25 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
[chatbot, "state"],
|
| 25 |
-
allow_flagging="never",
|
| 26 |
-
)
|
| 27 |
|
| 28 |
demo.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
|
| 6 |
+
pipe = pipeline("translation", model="t5-base")
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def translate(text):
|
| 10 |
+
return pipe(text)[0]["translation_text"]
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
with gr.Blocks() as demo:
|
| 14 |
+
with gr.Row():
|
| 15 |
+
with gr.Column():
|
| 16 |
+
english = gr.Textbox(label="English text")
|
| 17 |
+
translate_btn = gr.Button(value="Translate")
|
| 18 |
+
with gr.Column():
|
| 19 |
+
german = gr.Textbox(label="German text")
|
| 20 |
+
|
| 21 |
+
translate_btn.click(translate, inputs=english, outputs=german)
|
| 22 |
+
examples = gr.Examples(examples= ["I went to the supermarket yesterday.", "Heen is a good swimmer"],
|
| 23 |
+
inputs=[english])
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
demo.launch()
|