Spaces:
Running
Running
Daryl Lim Claude Sonnet 4.6 commited on
Commit ·
c077bcb
1
Parent(s): 5f9e08e
feat: rewrite UI with Google Translate-style layout
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -84,59 +84,37 @@ def _build_demo() -> gr.Blocks:
|
|
| 84 |
_, language_names = _build_language_mappings()
|
| 85 |
|
| 86 |
with gr.Blocks(title="MADLAD-400 Translation") as demo:
|
| 87 |
-
gr.Markdown(
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
with gr.Row():
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
placeholder="Enter English text here",
|
| 114 |
-
lines=4,
|
| 115 |
-
)
|
| 116 |
-
output_text = gr.Textbox(
|
| 117 |
-
label="Translation",
|
| 118 |
-
lines=4,
|
| 119 |
-
buttons=["copy"],
|
| 120 |
-
interactive=False,
|
| 121 |
-
)
|
| 122 |
-
|
| 123 |
-
single_btn = gr.Button("Translate", variant="primary")
|
| 124 |
-
|
| 125 |
-
single_btn.click(
|
| 126 |
-
fn=translate,
|
| 127 |
-
inputs=[input_text, target_language, max_new_tokens, num_beams, temperature],
|
| 128 |
-
outputs=output_text,
|
| 129 |
-
)
|
| 130 |
-
|
| 131 |
-
gr.Examples(
|
| 132 |
-
examples=[
|
| 133 |
-
["Hello, how are you today?", "French"],
|
| 134 |
-
["The weather is beautiful.", "Spanish"],
|
| 135 |
-
["Thank you very much.", "German"],
|
| 136 |
-
["Where is the train station?", "Portuguese"],
|
| 137 |
-
],
|
| 138 |
-
inputs=[input_text, target_language],
|
| 139 |
-
)
|
| 140 |
|
| 141 |
return demo
|
| 142 |
|
|
|
|
| 84 |
_, language_names = _build_language_mappings()
|
| 85 |
|
| 86 |
with gr.Blocks(title="MADLAD-400 Translation") as demo:
|
| 87 |
+
gr.Markdown("# MADLAD-400 Translation")
|
| 88 |
+
|
| 89 |
+
with gr.Row():
|
| 90 |
+
gr.Markdown("English →", container=False)
|
| 91 |
+
target_language = gr.Dropdown(
|
| 92 |
+
choices=language_names,
|
| 93 |
+
value="French",
|
| 94 |
+
label="Target language",
|
| 95 |
+
scale=0,
|
| 96 |
+
)
|
| 97 |
|
| 98 |
with gr.Row():
|
| 99 |
+
input_text = gr.Textbox(
|
| 100 |
+
label="English",
|
| 101 |
+
placeholder="Enter English text here",
|
| 102 |
+
lines=4,
|
| 103 |
+
)
|
| 104 |
+
output_text = gr.Textbox(
|
| 105 |
+
label="Translation",
|
| 106 |
+
lines=4,
|
| 107 |
+
buttons=["copy"],
|
| 108 |
+
interactive=False,
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
translate_btn = gr.Button("Translate", variant="primary")
|
| 112 |
+
|
| 113 |
+
translate_btn.click(
|
| 114 |
+
fn=translate,
|
| 115 |
+
inputs=[input_text, target_language],
|
| 116 |
+
outputs=output_text,
|
| 117 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
return demo
|
| 120 |
|