Spaces:
Sleeping
Sleeping
seyoungsong
commited on
Commit
•
4152c07
1
Parent(s):
a20291c
app.py
CHANGED
@@ -1,9 +1,30 @@
|
|
1 |
import gradio as gr
|
2 |
|
|
|
3 |
|
4 |
-
def greet(name):
|
5 |
-
return "Hello " + name + "!!"
|
6 |
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
lang_list = ["Korean", "English", "Chinese"]
|
4 |
|
|
|
|
|
5 |
|
6 |
+
def translate(prompt: str, source_lang: str, target_lang: str) -> str:
|
7 |
+
return f'"{prompt}" in {source_lang} means "{prompt}" in {target_lang}'
|
8 |
|
9 |
+
|
10 |
+
inputs = [
|
11 |
+
gr.Textbox(lines=4, value="Hello world!", label="Input Text"),
|
12 |
+
gr.Dropdown(lang_list, value="English", label="Source Language"),
|
13 |
+
gr.Dropdown(lang_list, value="Korean", label="Target Language"),
|
14 |
+
]
|
15 |
+
|
16 |
+
|
17 |
+
outputs = gr.Textbox(label="Output Text")
|
18 |
+
|
19 |
+
|
20 |
+
demo = gr.Interface(
|
21 |
+
fn=translate,
|
22 |
+
inputs=inputs,
|
23 |
+
outputs=outputs,
|
24 |
+
title="Beyond English-Centric Multilingual Machine Translation",
|
25 |
+
)
|
26 |
+
|
27 |
+
if __name__ == "__main__":
|
28 |
+
# gradio src/pretrained/gradio/app.py
|
29 |
+
# http://127.0.0.1:7860
|
30 |
+
demo.launch()
|