Spaces:
Running
Running
Daryl Lim Claude Opus 4.6 commited on
Commit ·
02f6bf9
1
Parent(s): 7a83d46
feat: replace gr.Interface with gr.Blocks for improved UI
Browse filesTwo-column layout, Soft theme, searchable dropdown, copy button,
and example translations for a friendlier experience.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -68,17 +68,49 @@ def translate(text: str, target_language_name: str) -> str:
|
|
| 68 |
def main() -> None:
|
| 69 |
_, language_names = _build_language_mappings()
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
demo.launch()
|
| 84 |
|
|
|
|
| 68 |
def main() -> None:
|
| 69 |
_, language_names = _build_language_mappings()
|
| 70 |
|
| 71 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="MADLAD-400 Translation") as demo:
|
| 72 |
+
gr.Markdown(
|
| 73 |
+
"# MADLAD-400 Translation\n"
|
| 74 |
+
"Translate English into 183 languages using Google's MADLAD-400 3B model. "
|
| 75 |
+
"[Paper](https://arxiv.org/pdf/2309.04662)"
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
target_language = gr.Dropdown(
|
| 79 |
+
choices=language_names,
|
| 80 |
+
value="French",
|
| 81 |
+
label="Target language",
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
with gr.Row():
|
| 85 |
+
input_text = gr.Textbox(
|
| 86 |
+
label="English",
|
| 87 |
+
placeholder="Enter English text here",
|
| 88 |
+
lines=4,
|
| 89 |
+
)
|
| 90 |
+
output_text = gr.Textbox(
|
| 91 |
+
label="Translation",
|
| 92 |
+
lines=4,
|
| 93 |
+
buttons=["copy"],
|
| 94 |
+
interactive=False,
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
translate_btn = gr.Button("Translate", variant="primary")
|
| 98 |
+
|
| 99 |
+
translate_btn.click(
|
| 100 |
+
fn=translate,
|
| 101 |
+
inputs=[input_text, target_language],
|
| 102 |
+
outputs=output_text,
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
gr.Examples(
|
| 106 |
+
examples=[
|
| 107 |
+
["Hello, how are you today?", "French"],
|
| 108 |
+
["The weather is beautiful.", "Japanese"],
|
| 109 |
+
["Thank you very much.", "Swahili"],
|
| 110 |
+
["Where is the train station?", "Hindi"],
|
| 111 |
+
],
|
| 112 |
+
inputs=[input_text, target_language],
|
| 113 |
+
)
|
| 114 |
|
| 115 |
demo.launch()
|
| 116 |
|