Daryl Lim Claude Sonnet 4.6 commited on
Commit
c077bcb
·
1 Parent(s): 5f9e08e

feat: rewrite UI with Google Translate-style layout

Browse files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +29 -51
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
- "# MADLAD-400 Translation\n"
89
- "Translate English into 22 production-ready languages using Google's MADLAD-400 3B model. "
90
- "[Paper](https://arxiv.org/pdf/2309.04662)"
91
- )
 
 
 
 
 
92
 
93
  with gr.Row():
94
- # --- Sidebar ---
95
- with gr.Column(scale=1, min_width=250):
96
- gr.Markdown("### Settings")
97
-
98
- target_language = gr.Dropdown(
99
- choices=language_names,
100
- value="French",
101
- label="Target language",
102
- )
103
- max_new_tokens = gr.Slider(minimum=1, maximum=1024, value=512, step=1, label="Max new tokens")
104
- num_beams = gr.Slider(minimum=1, maximum=10, value=1, step=1, label="Num beams")
105
- temperature = gr.Slider(minimum=0.1, maximum=2.0, value=1.0, step=0.1, label="Temperature")
106
-
107
- # --- Main area ---
108
- with gr.Column(scale=3):
109
- with gr.Tab("Single"):
110
- with gr.Row():
111
- input_text = gr.Textbox(
112
- label="English",
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 &rarr;", 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