LittleApple-fp16 commited on
Commit
5977b45
·
verified ·
1 Parent(s): 2840f99

Update waifuc_gui/interface.py

Browse files
Files changed (1) hide show
  1. waifuc_gui/interface.py +28 -26
waifuc_gui/interface.py CHANGED
@@ -77,9 +77,9 @@ class Interface:
77
  updates = []
78
  for source, source_params in self.params.items():
79
  for param_name, param_input in source_params.items():
80
- updates.append(param_input.update(visible=(source == selected_source)))
81
  local_source_info_visible = selected_source == "LocalSource"
82
- return updates + [gr.Markdown.update(visible=local_source_info_visible)]
83
 
84
  def collect_params(self, selected_source, *param_values):
85
  collected = {}
@@ -102,7 +102,6 @@ class Interface:
102
  ):
103
  output_dir = f"/tmp/user_{source_manager.config_manager.session_id}/{dataset_name}"
104
  try:
105
- output_dir = f"/tmp/user_{source_manager.config_manager.session_id}/{dataset_name}"
106
  logger = logging.getLogger("waifuc_gui")
107
  logger.info(f"Starting collection for {selected_source} with dataset {dataset_name}")
108
  os.makedirs(output_dir, exist_ok=True)
@@ -217,30 +216,33 @@ class Interface:
217
  new_param_components = [param_input for source_params in new_params.values() for param_input in source_params.values()]
218
  action_params = self.action_manager.create_action_param_inputs(action_checkboxes.value or [])
219
  new_action_param_inputs = [param_input for action_params_dict in action_params.values() for param_input in action_params_dict.values()]
220
- return {
221
- language_dropdown: gr.Dropdown(label=self.get_text("language")),
222
- source_dropdown: gr.Dropdown(label=self.get_text("select_source")),
223
- action_checkboxes: gr.CheckboxGroup(label=self.get_text("select_actions")),
224
- dataset_name_input: gr.Textbox(label=self.get_text("dataset_name")),
225
- exporter_dropdown: gr.Dropdown(label=self.get_text("select_exporter")),
226
- start_btn: gr.Button(self.get_text("start_collection")),
227
- status: gr.Textbox(label=self.get_text("status")),
228
- output_file: gr.File(label=self.get_text("download_data")),
229
- pixiv_token_input: gr.Textbox(label=self.get_text("pixiv_token")),
230
- output_dir_input: gr.Textbox(label=self.get_text("output_dir")),
231
- num_items_input: gr.Number(label=self.get_text("num_items")),
232
- resize_size_input: gr.Number(label=self.get_text("resize_size")),
233
- config_export_btn: gr.Button(self.get_text("export_config")),
234
- config_import_file: gr.File(label=self.get_text("import_config")),
235
- save_config_btn: gr.Button(self.get_text("save_config")),
236
- config_status: gr.Textbox(label=self.get_text("config_status")),
237
- log_output: gr.Textbox(label=self.get_text("view_logs")),
238
- log_download_btn: gr.Button(self.get_text("download_log")),
239
- log_download_file: gr.File(label=self.get_text("download_log")),
240
- local_source_info: gr.Markdown(self.get_text("local_source_info"), visible=source_dropdown.value == "LocalSource"),
241
- **{comp: new_comp for comp, new_comp in zip(param_components, new_param_components)},
242
- **{comp: new_comp for comp, new_comp in zip(action_param_inputs, new_action_param_inputs)}
243
  }
 
 
 
 
 
244
 
245
  language_dropdown.change(
246
  fn=update_language,
 
77
  updates = []
78
  for source, source_params in self.params.items():
79
  for param_name, param_input in source_params.items():
80
+ updates.append(gr.update(visible=(source == selected_source)))
81
  local_source_info_visible = selected_source == "LocalSource"
82
+ return updates + [gr.update(visible=local_source_info_visible)]
83
 
84
  def collect_params(self, selected_source, *param_values):
85
  collected = {}
 
102
  ):
103
  output_dir = f"/tmp/user_{source_manager.config_manager.session_id}/{dataset_name}"
104
  try:
 
105
  logger = logging.getLogger("waifuc_gui")
106
  logger.info(f"Starting collection for {selected_source} with dataset {dataset_name}")
107
  os.makedirs(output_dir, exist_ok=True)
 
216
  new_param_components = [param_input for source_params in new_params.values() for param_input in source_params.values()]
217
  action_params = self.action_manager.create_action_param_inputs(action_checkboxes.value or [])
218
  new_action_param_inputs = [param_input for action_params_dict in action_params.values() for param_input in action_params_dict.values()]
219
+ updates = {
220
+ language_dropdown: gr.update(label=self.get_text("language")),
221
+ source_dropdown: gr.update(label=self.get_text("select_source")),
222
+ action_checkboxes: gr.update(label=self.get_text("select_actions")),
223
+ dataset_name_input: gr.update(label=self.get_text("dataset_name")),
224
+ exporter_dropdown: gr.update(label=self.get_text("select_exporter")),
225
+ start_btn: gr.update(value=self.get_text("start_collection")),
226
+ status: gr.update(label=self.get_text("status")),
227
+ output_file: gr.update(label=self.get_text("download_data")),
228
+ pixiv_token_input: gr.update(label=self.get_text("pixiv_token")),
229
+ output_dir_input: gr.update(label=self.get_text("output_dir")),
230
+ num_items_input: gr.update(label=self.get_text("num_items")),
231
+ resize_size_input: gr.update(label=self.get_text("resize_size")),
232
+ config_export_btn: gr.update(value=self.get_text("export_config")),
233
+ config_import_file: gr.update(label=self.get_text("import_config")),
234
+ save_config_btn: gr.update(value=self.get_text("save_config")),
235
+ config_status: gr.update(label=self.get_text("config_status")),
236
+ log_output: gr.update(label=self.get_text("view_logs")),
237
+ log_download_btn: gr.update(value=self.get_text("download_log")),
238
+ log_download_file: gr.update(label=self.get_text("download_log")),
239
+ local_source_info: gr.update(value=self.get_text("local_source_info"), visible=source_dropdown.value == "LocalSource"),
 
 
240
  }
241
+ for old_comp, new_comp in zip(param_components, new_param_components):
242
+ updates[old_comp] = new_comp
243
+ for old_comp, new_comp in zip(action_param_inputs, new_action_param_inputs):
244
+ updates[old_comp] = new_comp
245
+ return updates
246
 
247
  language_dropdown.change(
248
  fn=update_language,