Spaces:
Running
Running
Split testing and tuning
Browse files
ui.py
CHANGED
|
@@ -144,7 +144,7 @@ def _render_dataset_tab(engine_state):
|
|
| 144 |
}
|
| 145 |
|
| 146 |
def _render_training_tab(engine_state):
|
| 147 |
-
with gr.TabItem("2. Training"):
|
| 148 |
gr.Markdown("### 🚀 Fine-Tuning Configuration")
|
| 149 |
with gr.Group():
|
| 150 |
gr.Markdown("**Hyperparameters**")
|
|
@@ -171,6 +171,7 @@ def _render_training_tab(engine_state):
|
|
| 171 |
|
| 172 |
return {
|
| 173 |
"params": [param_epochs, param_lr, param_test_size, param_shuffle, param_model],
|
|
|
|
| 174 |
"buttons": [run_training_btn, stop_training_btn, clear_reload_btn, run_eval_btn],
|
| 175 |
"outputs": [output_display, loss_plot],
|
| 176 |
"model_input": param_model # specifically needed for initialization
|
|
@@ -219,7 +220,8 @@ def build_interface() -> gr.Blocks:
|
|
| 219 |
# Helpers for UI State
|
| 220 |
# 'action_buttons' now ONLY contains buttons that should always be enabled after a process
|
| 221 |
# Zip and Push buttons are excluded here because their state depends on has_model_tuned
|
| 222 |
-
|
|
|
|
| 223 |
|
| 224 |
repo_input = export_ui["hub_controls"][0]
|
| 225 |
push_btn = export_ui["hub_controls"][1]
|
|
@@ -269,17 +271,18 @@ def build_interface() -> gr.Blocks:
|
|
| 269 |
outputs=[data_ui["import_status"]]
|
| 270 |
)
|
| 271 |
|
| 272 |
-
# 3. Training Tab
|
| 273 |
-
run_btn, stop_btn, reload_btn = train_ui["buttons"]
|
| 274 |
|
|
|
|
| 275 |
run_btn.click(
|
| 276 |
fn=lambda: (
|
| 277 |
gr.update(visible=False),
|
| 278 |
gr.update(interactive=False), # Lock Reload
|
|
|
|
| 279 |
gr.update(interactive=False), # Lock Zip
|
| 280 |
gr.update(visible=True) # Show Stop
|
| 281 |
),
|
| 282 |
-
outputs=[run_btn, reload_btn, zip_btn, stop_btn]
|
| 283 |
).then(
|
| 284 |
fn=UIController.run_training,
|
| 285 |
inputs=[engine_state, *train_ui["params"]],
|
|
@@ -288,9 +291,10 @@ def build_interface() -> gr.Blocks:
|
|
| 288 |
fn=lambda: (
|
| 289 |
gr.update(visible=True),
|
| 290 |
gr.update(interactive=True),
|
|
|
|
| 291 |
gr.update(visible=False)
|
| 292 |
),
|
| 293 |
-
outputs=[run_btn, reload_btn, stop_btn]
|
| 294 |
).then(
|
| 295 |
# Final check determines if Zip/Push should unlock
|
| 296 |
fn=UIController.update_hub_interactive,
|
|
@@ -298,6 +302,29 @@ def build_interface() -> gr.Blocks:
|
|
| 298 |
outputs=[repo_input, push_btn, zip_btn]
|
| 299 |
)
|
| 300 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
stop_btn.click(fn=UIController.stop_process, inputs=[engine_state])
|
| 302 |
|
| 303 |
reload_btn.click(lock_ui, outputs=action_buttons + [push_btn, zip_btn]).then(
|
|
@@ -337,4 +364,4 @@ def build_interface() -> gr.Blocks:
|
|
| 337 |
outputs=[repo_input, push_btn, zip_btn]
|
| 338 |
)
|
| 339 |
|
| 340 |
-
return demo
|
|
|
|
| 144 |
}
|
| 145 |
|
| 146 |
def _render_training_tab(engine_state):
|
| 147 |
+
with gr.TabItem("2. Training & Eval"):
|
| 148 |
gr.Markdown("### 🚀 Fine-Tuning Configuration")
|
| 149 |
with gr.Group():
|
| 150 |
gr.Markdown("**Hyperparameters**")
|
|
|
|
| 171 |
|
| 172 |
return {
|
| 173 |
"params": [param_epochs, param_lr, param_test_size, param_shuffle, param_model],
|
| 174 |
+
"eval_params": [param_test_size, param_shuffle, param_model],
|
| 175 |
"buttons": [run_training_btn, stop_training_btn, clear_reload_btn, run_eval_btn],
|
| 176 |
"outputs": [output_display, loss_plot],
|
| 177 |
"model_input": param_model # specifically needed for initialization
|
|
|
|
| 220 |
# Helpers for UI State
|
| 221 |
# 'action_buttons' now ONLY contains buttons that should always be enabled after a process
|
| 222 |
# Zip and Push buttons are excluded here because their state depends on has_model_tuned
|
| 223 |
+
run_btn, stop_btn, reload_btn, eval_btn = train_ui["buttons"]
|
| 224 |
+
action_buttons = [reload_btn, run_btn, eval_btn]
|
| 225 |
|
| 226 |
repo_input = export_ui["hub_controls"][0]
|
| 227 |
push_btn = export_ui["hub_controls"][1]
|
|
|
|
| 271 |
outputs=[data_ui["import_status"]]
|
| 272 |
)
|
| 273 |
|
| 274 |
+
# 3. Training & Eval Tab
|
|
|
|
| 275 |
|
| 276 |
+
# 3a. Training
|
| 277 |
run_btn.click(
|
| 278 |
fn=lambda: (
|
| 279 |
gr.update(visible=False),
|
| 280 |
gr.update(interactive=False), # Lock Reload
|
| 281 |
+
gr.update(interactive=False), # Lock Eval
|
| 282 |
gr.update(interactive=False), # Lock Zip
|
| 283 |
gr.update(visible=True) # Show Stop
|
| 284 |
),
|
| 285 |
+
outputs=[run_btn, reload_btn, eval_btn, zip_btn, stop_btn]
|
| 286 |
).then(
|
| 287 |
fn=UIController.run_training,
|
| 288 |
inputs=[engine_state, *train_ui["params"]],
|
|
|
|
| 291 |
fn=lambda: (
|
| 292 |
gr.update(visible=True),
|
| 293 |
gr.update(interactive=True),
|
| 294 |
+
gr.update(interactive=True),
|
| 295 |
gr.update(visible=False)
|
| 296 |
),
|
| 297 |
+
outputs=[run_btn, reload_btn, eval_btn, stop_btn]
|
| 298 |
).then(
|
| 299 |
# Final check determines if Zip/Push should unlock
|
| 300 |
fn=UIController.update_hub_interactive,
|
|
|
|
| 302 |
outputs=[repo_input, push_btn, zip_btn]
|
| 303 |
)
|
| 304 |
|
| 305 |
+
# 3b. Evaluation
|
| 306 |
+
eval_btn.click(
|
| 307 |
+
fn=lambda: (
|
| 308 |
+
gr.update(interactive=False), # Lock Run
|
| 309 |
+
gr.update(interactive=False), # Lock Reload
|
| 310 |
+
gr.update(visible=False), # Hide self (optional, or lock)
|
| 311 |
+
gr.update(visible=True) # Show Stop
|
| 312 |
+
),
|
| 313 |
+
outputs=[run_btn, reload_btn, eval_btn, stop_btn]
|
| 314 |
+
).then(
|
| 315 |
+
fn=UIController.run_evaluation,
|
| 316 |
+
inputs=[engine_state, *train_ui["eval_params"]],
|
| 317 |
+
outputs=[train_ui["outputs"][0]] # Output only to log, not plot
|
| 318 |
+
).then(
|
| 319 |
+
fn=lambda: (
|
| 320 |
+
gr.update(interactive=True),
|
| 321 |
+
gr.update(interactive=True),
|
| 322 |
+
gr.update(visible=True),
|
| 323 |
+
gr.update(visible=False)
|
| 324 |
+
),
|
| 325 |
+
outputs=[run_btn, reload_btn, eval_btn, stop_btn]
|
| 326 |
+
)
|
| 327 |
+
|
| 328 |
stop_btn.click(fn=UIController.stop_process, inputs=[engine_state])
|
| 329 |
|
| 330 |
reload_btn.click(lock_ui, outputs=action_buttons + [push_btn, zip_btn]).then(
|
|
|
|
| 364 |
outputs=[repo_input, push_btn, zip_btn]
|
| 365 |
)
|
| 366 |
|
| 367 |
+
return demo
|