Skip to content

Commit 6c1b4df

Browse files
committed
UI: convert training steps from Accordion to sub TabItems
- Replace 5 Accordion sections with TabItem tabs for cleaner navigation - Steps now: 1.Preprocess | 2.Extract | 3.Index | 4.Train | 5.Export - Removed _section() helper and all markdown headers (no more ### clutter) - Advanced Settings collapsed into Accordion inside Train tab - Index button now outputs to its own info box instead of training_info - Cleaner, more compact layout — no scrolling through collapsed accordions
1 parent 44ff1fe commit 6c1b4df

1 file changed

Lines changed: 13 additions & 34 deletions

File tree

arvc/app/tabs/training/child/training.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,11 @@
1010
from arvc.engine.models.optimizers import get_optimizer_choices, get_optimizer_info
1111
from arvc.engine.models.generators import get_vocoder_choices
1212

13-
# ── Styled section label (replaces ugly ### headers) ──────────────────────
14-
def _section(title):
15-
"""Render a clean section label with a subtle left accent bar."""
16-
return gr.HTML(
17-
f'<div style="display:flex;align-items:center;gap:8px;margin:4px 0 2px 0;">'
18-
f'<span style="width:3px;height:18px;border-radius:2px;background:linear-gradient(180deg,#6366f1,#8b5cf6);display:inline-block;"></span>'
19-
f'<span style="font-size:13px;font-weight:600;color:#c4b5fd;letter-spacing:0.3px;">{title}</span>'
20-
f'</div>'
21-
)
22-
2313

2414
def training_model_tab():
2515
with gr.Column():
26-
gr.Markdown(translations["training_markdown"])
27-
28-
# ── Step 1: Dataset Preprocessing ──
29-
with gr.Accordion("1. Dataset Preprocessing", open=True):
16+
# ── Sub-tab 1: Dataset Preprocessing ──
17+
with gr.TabItem("1. Preprocess"):
3018
training_name = gr.Textbox(
3119
label=translations["modelname"],
3220
info=translations["training_model_name"],
@@ -108,11 +96,10 @@ def training_model_tab():
10896
preprocess_button = gr.Button(translations["preprocess_button"], variant="primary")
10997
preprocess_info = gr.Textbox(label=translations["preprocess_info"], value="", interactive=False, lines=2)
11098

111-
# ── Step 2: Feature Extraction ──
112-
with gr.Accordion("2. Feature Extraction", open=False):
99+
# ── Sub-tab 2: Feature Extraction ──
100+
with gr.TabItem("2. Extract"):
113101
with gr.Row(equal_height=False):
114102
with gr.Column(scale=1):
115-
_section(translations['f0_method'])
116103
onnx_f0_mode2 = gr.Checkbox(label=translations["f0_onnx_mode"], value=False, interactive=True)
117104
unlock_full_method4 = gr.Checkbox(label=translations["f0_unlock"], value=False, interactive=True)
118105
autotune = gr.Checkbox(label=translations["autotune"], value=False, interactive=True)
@@ -142,7 +129,6 @@ def training_model_tab():
142129
)
143130

144131
with gr.Column(scale=1):
145-
_section(translations['hubert_model'])
146132
embed_mode2 = gr.Radio(
147133
label=translations["embed_mode"], info=translations["embed_mode_info"],
148134
value="fairseq", choices=embedders_mode, interactive=True,
@@ -161,19 +147,19 @@ def training_model_tab():
161147
extract_button = gr.Button(translations["extract_button"], variant="primary")
162148
extract_info = gr.Textbox(label=translations["extract_info"], value="", interactive=False, lines=2)
163149

164-
# ── Step 3: Index Creation ──
165-
with gr.Accordion("3. Index Creation", open=False):
150+
# ── Sub-tab 3: Index Creation ──
151+
with gr.TabItem("3. Index"):
166152
index_algorithm = gr.Radio(
167153
label=translations["index_algorithm"], info=translations["index_algorithm_info"],
168154
choices=["Auto", "Faiss", "KMeans"], value="Auto", interactive=True,
169155
)
170156
index_button = gr.Button(translations["create_index"], variant="secondary")
157+
index_info = gr.Textbox(label=translations["create_index"], value="", interactive=False, lines=2)
171158

172-
# ── Step 4: Model Training ──
173-
with gr.Accordion("4. Model Training", open=False):
159+
# ── Sub-tab 4: Model Training ──
160+
with gr.TabItem("4. Train"):
174161
# ── Training Parameters ──
175162
with gr.Group():
176-
_section("Training Parameters")
177163
with gr.Row(equal_height=False):
178164
with gr.Column(scale=1):
179165
total_epochs = gr.Slider(
@@ -208,7 +194,6 @@ def training_model_tab():
208194

209195
# ── PyTorch Weight Format ──
210196
with gr.Group():
211-
_section("PyTorch Weight Format")
212197
newpytorch = gr.Checkbox(
213198
label="New PyTorch 2.0+ Format",
214199
info="Default: OFF = Old format (.weight_g/.weight_v) for broad RVC fork compatibility. Turn ON for PyTorch 2.0+ parametrization format.",
@@ -217,7 +202,6 @@ def training_model_tab():
217202

218203
# ── Training Options ──
219204
with gr.Group():
220-
_section("Training Options")
221205
with gr.Row():
222206
cache_in_gpu = gr.Checkbox(label=translations["cache_in_gpu"], info=translations["cache_in_gpu_info"], value=True, interactive=True)
223207
overtraining_detector = gr.Checkbox(label=translations["overtraining_detector"], info=translations["overtraining_detector_info"], value=False, interactive=True)
@@ -229,15 +213,13 @@ def training_model_tab():
229213

230214
# ── Pretrain & Dataset ──
231215
with gr.Group():
232-
_section("Pretrain & Dataset")
233216
with gr.Row():
234217
not_use_pretrain = gr.Checkbox(label=translations["not_use_pretrain_2"], info=translations["not_use_pretrain_info"], value=False, interactive=True)
235218
custom_pretrain = gr.Checkbox(label=translations["custom_pretrain"], info=translations["custom_pretrain_info"], value=False, interactive=True)
236219
custom_dataset = gr.Checkbox(label=translations["custom_dataset"], info=translations["custom_dataset_info"], value=False, interactive=True)
237220

238221
# ── Advanced Settings ──
239-
with gr.Group():
240-
_section("Advanced Settings")
222+
with gr.Accordion("Advanced Settings", open=False):
241223
with gr.Row():
242224
multiscale_mel_loss = gr.Checkbox(label=translations["multiscale_mel_loss"], info=translations["multiscale_mel_loss_info"], value=False, interactive=True)
243225
cosine_lr = gr.Checkbox(label="Cosine Annealing LR", info="Use CosineAnnealingLR scheduler for better training quality (recommended)", value=True, interactive=True)
@@ -250,7 +232,6 @@ def training_model_tab():
250232
pretrain_setting = gr.Group(visible=False)
251233
with pretrain_setting:
252234
with gr.Accordion(translations["custom_pretrain_info"], open=True):
253-
_section(translations.get('select_pretrain', 'Select from pretrained list'))
254235
pretrained_data = fetch_pretrained_data()
255236
_pretrained_names = list(pretrained_data.keys()) if pretrained_data else []
256237
_first_model = _pretrained_names[0] if _pretrained_names else ''
@@ -267,7 +248,6 @@ def training_model_tab():
267248
value=_first_sr_choices[0] if _first_sr_choices else '',
268249
interactive=True,
269250
)
270-
_section(translations.get('custom_pretrain_info', 'Or select files manually'))
271251
with gr.Row():
272252
pretrained_D = gr.Dropdown(
273253
label=translations["pretrain_file"].format(dg="D"),
@@ -294,7 +274,6 @@ def on_pretrained_sr_select(model, sr):
294274
if not data or model not in data or sr not in data[model]:
295275
return gr.update(), gr.update()
296276
paths = data[model][sr]
297-
# paths can be a string like "D_file.pth, G_file.pth" or a dict
298277
if isinstance(paths, str):
299278
parts = [p.strip() for p in paths.split(",")]
300279
g_val = parts[-1] if len(parts) > 1 else ''
@@ -326,8 +305,8 @@ def on_pretrained_sr_select(model, sr):
326305
training_button = gr.Button(translations["training_model"], variant="primary")
327306
training_info = gr.Textbox(label=translations["train_info"], value="", interactive=False, lines=4)
328307

329-
# ── Export Model ──
330-
with gr.Accordion("5. Export Model", open=False):
308+
# ── Sub-tab 5: Export Model ──
309+
with gr.TabItem("5. Export"):
331310
with gr.Row():
332311
model_file = gr.Dropdown(
333312
label=translations["model_name"], choices=model_name,
@@ -399,7 +378,7 @@ def on_pretrained_sr_select(model, sr):
399378
index_button.click(
400379
fn=create_index,
401380
inputs=[training_name, training_ver, index_algorithm],
402-
outputs=[training_info],
381+
outputs=[index_info],
403382
api_name="create_index"
404383
)
405384
training_button.click(

0 commit comments

Comments
 (0)