jbilcke-hf HF Staff commited on
Commit
6fff6df
·
1 Parent(s): 2ba9257

Fix dropdown mismatch error when changing training preset

Browse files
degraded_requirements.txt CHANGED
@@ -38,6 +38,7 @@ git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
38
  # for our frontend
39
  gradio==5.23.3
40
  gradio_toggle
 
41
 
42
  # used for the monitor
43
  matplotlib
 
38
  # for our frontend
39
  gradio==5.23.3
40
  gradio_toggle
41
+ gradio_modal
42
 
43
  # used for the monitor
44
  matplotlib
requirements.txt CHANGED
@@ -36,6 +36,7 @@ git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
36
  # for our frontend
37
  gradio==5.23.3
38
  gradio_toggle
 
39
 
40
  # used for the monitor
41
  matplotlib
 
36
  # for our frontend
37
  gradio==5.23.3
38
  gradio_toggle
39
+ gradio_modal
40
 
41
  # used for the monitor
42
  matplotlib
vms/ui/app_ui.py CHANGED
@@ -269,8 +269,8 @@ class AppUI:
269
  prose_header_text_weight='400'
270
  ),
271
 
272
- # Let's hack Gradio!
273
- css="#main-tabs > .tab-wrapper{ display: none; }",
274
  ) as app:
275
  self.app = app
276
 
 
269
  prose_header_text_weight='400'
270
  ),
271
 
272
+ # Let's hack Gradio and gradio_modal!
273
+ css="#main-tabs > .tab-wrapper{ display: none; } .modal{ z-index: 1000; } .modal-block{ max-width: 420px; }",
274
  ) as app:
275
  self.app = app
276
 
vms/ui/models/tabs/drafts_tab.py CHANGED
@@ -6,6 +6,7 @@ import gradio as gr
6
  import logging
7
  from typing import Dict, Any, List, Optional, Tuple
8
  from datetime import datetime
 
9
 
10
  from vms.utils.base_tab import BaseTab
11
 
@@ -92,22 +93,49 @@ class DraftsTab(BaseTab):
92
  )
93
  with gr.Column(scale=1, min_width=10):
94
  delete_btn = gr.Button("🗑️ Delete", size="sm", variant="stop")
95
-
 
 
 
 
 
 
 
 
 
 
 
96
  delete_btn.click(
 
 
 
 
 
 
 
 
 
 
 
 
97
  fn=lambda model_id=model.id: self.delete_model(model_id),
98
  inputs=[],
99
  outputs=[new_container]
 
 
 
 
100
  )
101
 
102
  return new_container
103
 
104
- def edit_model(self, model_id: str) -> None:
105
  """Switch to editing the selected model"""
106
  if self.app:
107
  # Switch to project view with this model
108
  self.app.switch_project(model_id)
109
  # Set main tab to Project (index 0)
110
- return self.app.main_tabs.update(selected=0)
111
 
112
  def delete_model(self, model_id: str) -> gr.Column:
113
  """Delete a model and refresh the list"""
 
6
  import logging
7
  from typing import Dict, Any, List, Optional, Tuple
8
  from datetime import datetime
9
+ from gradio_modal import Modal
10
 
11
  from vms.utils.base_tab import BaseTab
12
 
 
93
  )
94
  with gr.Column(scale=1, min_width=10):
95
  delete_btn = gr.Button("🗑️ Delete", size="sm", variant="stop")
96
+
97
+ # Create a modal for this specific model deletion
98
+ with Modal(visible=False) as delete_modal:
99
+ gr.Markdown("## ⚠️ Confirm Deletion")
100
+ gr.Markdown(f"Are you sure you want to delete model {model.id[:8]}...?")
101
+ gr.Markdown("This action cannot be undone!")
102
+
103
+ with gr.Row():
104
+ cancel_btn = gr.Button("🫢 No, cancel", variant="secondary")
105
+ confirm_btn = gr.Button("🚨 Yes, delete", variant="primary")
106
+
107
+ # Connect the buttons to the modal
108
  delete_btn.click(
109
+ fn=lambda: Modal(visible=True),
110
+ inputs=[],
111
+ outputs=[delete_modal]
112
+ )
113
+
114
+ cancel_btn.click(
115
+ fn=lambda: Modal(visible=False),
116
+ inputs=[],
117
+ outputs=[delete_modal]
118
+ )
119
+
120
+ confirm_btn.click(
121
  fn=lambda model_id=model.id: self.delete_model(model_id),
122
  inputs=[],
123
  outputs=[new_container]
124
+ ).then(
125
+ fn=lambda: Modal(visible=False),
126
+ inputs=[],
127
+ outputs=[delete_modal]
128
  )
129
 
130
  return new_container
131
 
132
+ def edit_model(self, model_id: str) -> gr.Tabs:
133
  """Switch to editing the selected model"""
134
  if self.app:
135
  # Switch to project view with this model
136
  self.app.switch_project(model_id)
137
  # Set main tab to Project (index 0)
138
+ return gr.Tabs(selected=0)
139
 
140
  def delete_model(self, model_id: str) -> gr.Column:
141
  """Delete a model and refresh the list"""
vms/ui/models/tabs/trained_tab.py CHANGED
@@ -5,6 +5,7 @@ Trained tab for Models view in Video Model Studio UI
5
  import gradio as gr
6
  import logging
7
  from typing import Dict, Any, List, Optional, Tuple
 
8
 
9
  from vms.utils.base_tab import BaseTab
10
 
@@ -90,6 +91,16 @@ class TrainedTab(BaseTab):
90
  publish_btn = gr.Button("🌐 Publish", size="sm")
91
  delete_btn = gr.Button("🗑️ Delete", size="sm", variant="stop")
92
 
 
 
 
 
 
 
 
 
 
 
93
  # Connect event handlers for this specific model
94
  preview_btn.click(
95
  fn=lambda model_id=model.id: self.preview_model(model_id),
@@ -109,10 +120,29 @@ class TrainedTab(BaseTab):
109
  outputs=[self.app.main_tabs]
110
  )
111
 
 
112
  delete_btn.click(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  fn=lambda model_id=model.id: self.delete_model(model_id),
114
  inputs=[],
115
  outputs=[new_container]
 
 
 
 
116
  )
117
 
118
  return new_container
 
5
  import gradio as gr
6
  import logging
7
  from typing import Dict, Any, List, Optional, Tuple
8
+ from gradio_modal import Modal
9
 
10
  from vms.utils.base_tab import BaseTab
11
 
 
91
  publish_btn = gr.Button("🌐 Publish", size="sm")
92
  delete_btn = gr.Button("🗑️ Delete", size="sm", variant="stop")
93
 
94
+ # Create a modal for this specific model deletion
95
+ with Modal(visible=False) as delete_modal:
96
+ gr.Markdown("## ⚠️ Confirm Deletion")
97
+ gr.Markdown(f"Are you sure you want to delete model {model.id[:8]}...?")
98
+ gr.Markdown("This action cannot be undone!")
99
+
100
+ with gr.Row():
101
+ cancel_btn = gr.Button("🫢 No, cancel", variant="secondary")
102
+ confirm_btn = gr.Button("🚨 Yes, delete", variant="primary")
103
+
104
  # Connect event handlers for this specific model
105
  preview_btn.click(
106
  fn=lambda model_id=model.id: self.preview_model(model_id),
 
120
  outputs=[self.app.main_tabs]
121
  )
122
 
123
+ # Connect delete button to show modal
124
  delete_btn.click(
125
+ fn=lambda: Modal(visible=True),
126
+ inputs=[],
127
+ outputs=[delete_modal]
128
+ )
129
+
130
+ # Connect cancel button to hide modal
131
+ cancel_btn.click(
132
+ fn=lambda: Modal(visible=False),
133
+ inputs=[],
134
+ outputs=[delete_modal]
135
+ )
136
+
137
+ # Connect confirm button to delete and hide modal
138
+ confirm_btn.click(
139
  fn=lambda model_id=model.id: self.delete_model(model_id),
140
  inputs=[],
141
  outputs=[new_container]
142
+ ).then(
143
+ fn=lambda: Modal(visible=False),
144
+ inputs=[],
145
+ outputs=[delete_modal]
146
  )
147
 
148
  return new_container
vms/ui/project/tabs/manage_tab.py CHANGED
@@ -7,6 +7,7 @@ import logging
7
  import shutil
8
  from pathlib import Path
9
  from typing import Dict, Any, List, Optional
 
10
 
11
  from vms.utils import BaseTab, validate_model_repo
12
  from vms.config import (
@@ -90,6 +91,20 @@ class ManageTab(BaseTab):
90
  interactive=False,
91
  visible=False
92
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
  with gr.Column(scale=1):
95
  self.components["delete_model_btn"] = gr.Button(
@@ -101,6 +116,20 @@ class ManageTab(BaseTab):
101
  interactive=False,
102
  visible=False
103
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  with gr.Row():
106
  with gr.Column():
@@ -117,6 +146,24 @@ class ManageTab(BaseTab):
117
  interactive=False,
118
  visible=False
119
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
  return tab
122
 
@@ -140,26 +187,76 @@ class ManageTab(BaseTab):
140
  outputs=[self.components["download_model_btn"]]
141
  )
142
 
143
- # New delete dataset button
144
  self.components["delete_dataset_btn"].click(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  fn=self.delete_dataset,
146
  outputs=[
147
  self.components["delete_dataset_status"],
148
  self.app.tabs["caption_tab"].components["training_dataset"]
149
  ]
 
 
 
 
150
  )
151
 
152
- # New delete model button
153
  self.components["delete_model_btn"].click(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  fn=self.delete_model,
155
  outputs=[
156
  self.components["delete_model_status"],
157
  self.app.tabs["train_tab"].components["status_box"]
158
  ]
 
 
 
 
159
  )
160
 
161
- # Global stop button
162
  self.components["global_stop_btn"].click(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  fn=self.handle_global_stop,
164
  outputs=[
165
  self.components["global_status"],
@@ -169,6 +266,10 @@ class ManageTab(BaseTab):
169
  self.app.tabs["import_tab"].components["import_status"],
170
  self.app.tabs["caption_tab"].components["preview_status"]
171
  ]
 
 
 
 
172
  )
173
 
174
  # Push model button
 
7
  import shutil
8
  from pathlib import Path
9
  from typing import Dict, Any, List, Optional
10
+ from gradio_modal import Modal
11
 
12
  from vms.utils import BaseTab, validate_model_repo
13
  from vms.config import (
 
91
  interactive=False,
92
  visible=False
93
  )
94
+
95
+ # Modal for dataset deletion confirmation
96
+ with Modal(visible=False) as dataset_delete_modal:
97
+ gr.Markdown("## ⚠️ Confirm Deletion")
98
+ gr.Markdown("Are you sure you want to delete all dataset files (images, videos, captions)?")
99
+ gr.Markdown("This action cannot be undone!")
100
+
101
+ with gr.Row():
102
+ cancel_dataset_btn = gr.Button("🫢 No, cancel", variant="secondary")
103
+ confirm_dataset_btn = gr.Button("🚨 Yes, delete", variant="primary")
104
+
105
+ self.components["dataset_delete_modal"] = dataset_delete_modal
106
+ self.components["cancel_dataset_btn"] = cancel_dataset_btn
107
+ self.components["confirm_dataset_btn"] = confirm_dataset_btn
108
 
109
  with gr.Column(scale=1):
110
  self.components["delete_model_btn"] = gr.Button(
 
116
  interactive=False,
117
  visible=False
118
  )
119
+
120
+ # Modal for model deletion confirmation
121
+ with Modal(visible=False) as model_delete_modal:
122
+ gr.Markdown("## ⚠️ Confirm Deletion")
123
+ gr.Markdown("Are you sure you want to delete all model files (checkpoints, weights, config)?")
124
+ gr.Markdown("This action cannot be undone!")
125
+
126
+ with gr.Row():
127
+ cancel_model_btn = gr.Button("🫢 No, cancel", variant="secondary")
128
+ confirm_model_btn = gr.Button("🚨 Yes, delete", variant="primary")
129
+
130
+ self.components["model_delete_modal"] = model_delete_modal
131
+ self.components["cancel_model_btn"] = cancel_model_btn
132
+ self.components["confirm_model_btn"] = confirm_model_btn
133
 
134
  with gr.Row():
135
  with gr.Column():
 
146
  interactive=False,
147
  visible=False
148
  )
149
+
150
+ # Modal for global deletion confirmation
151
+ with Modal(visible=False) as global_delete_modal:
152
+ gr.Markdown("## ⚠️ Confirm Complete Data Deletion")
153
+ gr.Markdown("Are you sure you want to delete ALL project data and models?")
154
+ gr.Markdown("This includes:")
155
+ gr.Markdown("- All original datasets (images, videos, captions)")
156
+ gr.Markdown("- All training datasets")
157
+ gr.Markdown("- All model outputs (weights, checkpoints, settings)")
158
+ gr.Markdown("This action cannot be undone!")
159
+
160
+ with gr.Row():
161
+ cancel_global_btn = gr.Button("🫢 No, cancel", variant="secondary")
162
+ confirm_global_btn = gr.Button("🚨 Yes, delete", variant="primary")
163
+
164
+ self.components["global_delete_modal"] = global_delete_modal
165
+ self.components["cancel_global_btn"] = cancel_global_btn
166
+ self.components["confirm_global_btn"] = confirm_global_btn
167
 
168
  return tab
169
 
 
187
  outputs=[self.components["download_model_btn"]]
188
  )
189
 
190
+ # Dataset deletion with modal
191
  self.components["delete_dataset_btn"].click(
192
+ fn=lambda: Modal(visible=True),
193
+ inputs=[],
194
+ outputs=[self.components["dataset_delete_modal"]]
195
+ )
196
+
197
+ # Modal cancel button
198
+ self.components["cancel_dataset_btn"].click(
199
+ fn=lambda: Modal(visible=False),
200
+ inputs=[],
201
+ outputs=[self.components["dataset_delete_modal"]]
202
+ )
203
+
204
+ # Modal confirm button
205
+ self.components["confirm_dataset_btn"].click(
206
  fn=self.delete_dataset,
207
  outputs=[
208
  self.components["delete_dataset_status"],
209
  self.app.tabs["caption_tab"].components["training_dataset"]
210
  ]
211
+ ).then(
212
+ fn=lambda: Modal(visible=False),
213
+ inputs=[],
214
+ outputs=[self.components["dataset_delete_modal"]]
215
  )
216
 
217
+ # Model deletion with modal
218
  self.components["delete_model_btn"].click(
219
+ fn=lambda: Modal(visible=True),
220
+ inputs=[],
221
+ outputs=[self.components["model_delete_modal"]]
222
+ )
223
+
224
+ # Modal cancel button
225
+ self.components["cancel_model_btn"].click(
226
+ fn=lambda: Modal(visible=False),
227
+ inputs=[],
228
+ outputs=[self.components["model_delete_modal"]]
229
+ )
230
+
231
+ # Modal confirm button
232
+ self.components["confirm_model_btn"].click(
233
  fn=self.delete_model,
234
  outputs=[
235
  self.components["delete_model_status"],
236
  self.app.tabs["train_tab"].components["status_box"]
237
  ]
238
+ ).then(
239
+ fn=lambda: Modal(visible=False),
240
+ inputs=[],
241
+ outputs=[self.components["model_delete_modal"]]
242
  )
243
 
244
+ # Global stop button with modal
245
  self.components["global_stop_btn"].click(
246
+ fn=lambda: Modal(visible=True),
247
+ inputs=[],
248
+ outputs=[self.components["global_delete_modal"]]
249
+ )
250
+
251
+ # Modal cancel button
252
+ self.components["cancel_global_btn"].click(
253
+ fn=lambda: Modal(visible=False),
254
+ inputs=[],
255
+ outputs=[self.components["global_delete_modal"]]
256
+ )
257
+
258
+ # Modal confirm button
259
+ self.components["confirm_global_btn"].click(
260
  fn=self.handle_global_stop,
261
  outputs=[
262
  self.components["global_status"],
 
266
  self.app.tabs["import_tab"].components["import_status"],
267
  self.app.tabs["caption_tab"].components["preview_status"]
268
  ]
269
+ ).then(
270
+ fn=lambda: Modal(visible=False),
271
+ inputs=[],
272
+ outputs=[self.components["global_delete_modal"]]
273
  )
274
 
275
  # Push model button
vms/ui/project/tabs/train_tab.py CHANGED
@@ -1118,32 +1118,35 @@ class TrainTab(BaseTab):
1118
  # Create the model version dropdown update
1119
  model_version_update = gr.Dropdown(choices=model_versions, value=default_model_version)
1120
 
1121
- # Return values in the same order as the output components
 
1122
  return (
1123
- model_display_name,
1124
- training_display_name,
1125
- lora_rank_val,
1126
- lora_alpha_val,
1127
- train_steps_val,
1128
- batch_size_val,
1129
- learning_rate_val,
1130
- save_iterations_val,
1131
- info_text,
1132
- gr.Row(visible=show_lora_params),
1133
- num_gpus_val,
1134
- precomputation_items_val,
1135
- lr_warmup_steps_val,
1136
- model_version_update,
 
1137
  # Control parameters rows visibility
1138
- gr.Row(visible=show_control_params),
1139
- gr.Row(visible=show_control_params),
1140
- gr.Row(visible=show_control_params),
 
1141
  # Control parameter values
1142
- control_type_val,
1143
- train_qk_norm_val,
1144
- frame_conditioning_type_val,
1145
- frame_conditioning_index_val,
1146
- frame_conditioning_concatenate_mask_val,
1147
  )
1148
 
1149
 
 
1118
  # Create the model version dropdown update
1119
  model_version_update = gr.Dropdown(choices=model_versions, value=default_model_version)
1120
 
1121
+ # Return values in the same order as the output components listed in line 644
1122
+ # Make sure we return exactly 24 values to match what's expected
1123
  return (
1124
+ model_display_name, # model_type
1125
+ training_display_name, # training_type
1126
+ lora_rank_val, # lora_rank
1127
+ lora_alpha_val, # lora_alpha
1128
+ train_steps_val, # train_steps
1129
+ batch_size_val, # batch_size
1130
+ learning_rate_val, # learning_rate
1131
+ save_iterations_val, # save_iterations
1132
+ info_text, # preset_info
1133
+ gr.Row(visible=show_lora_params), # lora_params_row
1134
+ gr.Row(visible=show_lora_params), # lora_settings_row (added missing row)
1135
+ num_gpus_val, # num_gpus
1136
+ precomputation_items_val, # precomputation_items
1137
+ lr_warmup_steps_val, # lr_warmup_steps
1138
+ model_version_update, # model_version
1139
  # Control parameters rows visibility
1140
+ gr.Row(visible=show_control_params), # control_params_row
1141
+ gr.Row(visible=show_control_params), # control_settings_row
1142
+ gr.Row(visible=show_control_params), # frame_conditioning_row
1143
+ gr.Row(visible=show_control_params), # control_options_row
1144
  # Control parameter values
1145
+ control_type_val, # control_type
1146
+ train_qk_norm_val, # train_qk_norm
1147
+ frame_conditioning_type_val, # frame_conditioning_type
1148
+ frame_conditioning_index_val, # frame_conditioning_index
1149
+ frame_conditioning_concatenate_mask_val, # frame_conditioning_concatenate_mask
1150
  )
1151
 
1152