From bb73359772e322e5cffa81c6aa9aaf369541ac63 Mon Sep 17 00:00:00 2001 From: DeepBeepMeep Date: Fri, 11 Apr 2025 08:10:01 +0200 Subject: [PATCH] Code cleaning --- wan/modules/model.py | 2 +- wan/text2video.py | 6 +++--- wgp.py | 19 +++++++++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/wan/modules/model.py b/wan/modules/model.py index d006f9e..e7a76a9 100644 --- a/wan/modules/model.py +++ b/wan/modules/model.py @@ -960,7 +960,7 @@ class WanModel(ModelMixin, ConfigMixin): ]) kwargs['context_scale'] = vace_context_scale - hints_list = [ [c] if i==0 else [c.clone()] for i in range(len(x_list)) ] + hints_list = [ [c] for _ in range(len(x_list)) ] del c should_calc = True diff --git a/wan/text2video.py b/wan/text2video.py index d77414d..ba24e6d 100644 --- a/wan/text2video.py +++ b/wan/text2video.py @@ -511,9 +511,9 @@ class WanT2V: def adapt_vace_model(self): model = self.model modules_dict= { k: m for k, m in model.named_modules()} - for num in range(15): - module = modules_dict[f"vace_blocks.{num}"] - target = modules_dict[f"blocks.{2*num}"] + for model_layer, vace_layer in model.vace_layers_mapping.items(): + module = modules_dict[f"vace_blocks.{vace_layer}"] + target = modules_dict[f"blocks.{model_layer}"] setattr(target, "vace", module ) delattr(model, "vace_blocks") diff --git a/wgp.py b/wgp.py index eff8957..da7273a 100644 --- a/wgp.py +++ b/wgp.py @@ -421,7 +421,8 @@ def save_queue_action(state): if image_filenames_for_json: params_copy[key] = image_filenames_for_json if is_originally_list else image_filenames_for_json[0] else: - params_copy.pop(key, None) + pass + # params_copy.pop(key, None) #cant pop otherwise crash during reload for key in video_keys: video_path_orig = params_copy.get(key) @@ -885,6 +886,15 @@ def autoload_queue(state): update_global_queue_ref([]) dataframe_update = update_queue_data([]) + # need to remove queue otherwise every new tab will be processed it again + try: + if os.path.isfile(AUTOSAVE_FILENAME): + os.remove(AUTOSAVE_FILENAME) + print(f"Clear Queue: Deleted autosave file '{AUTOSAVE_FILENAME}'.") + except OSError as e: + print(f"Clear Queue: Error deleting autosave file '{AUTOSAVE_FILENAME}': {e}") + gr.Warning(f"Could not delete the autosave file '{AUTOSAVE_FILENAME}'. You may need to remove it manually.") + else: if original_queue: print("Autoload skipped: Queue is not empty.") @@ -895,6 +905,7 @@ def autoload_queue(state): update_global_queue_ref([]) dataframe_update = update_queue_data([]) + return dataframe_update, loaded_flag, state def run_autoload_and_prepare_ui(current_state): @@ -2313,10 +2324,10 @@ def generate_video( progress(*progress_args ) gen["progress_args"] = progress_args video_guide = preprocess_video(preprocess_type, width=width, height=height,video_in=video_guide, max_frames= video_length) - + image_refs = image_refs.copy() if image_refs != None else None # required since prepare_source do inplace modifications src_video, src_mask, src_ref_images = wan_model.prepare_source([video_guide], [video_mask], - [image_refs], + [image_refs], video_length, VACE_SIZE_CONFIGS[resolution_reformated], "cpu", original_video= "O" in video_prompt_type, trim_video=max_frames) @@ -3598,7 +3609,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non queue_df = gr.DataFrame( headers=["Qty","Prompt", "Length","Steps","", "", "", "", ""], datatype=[ "str","markdown","str", "markdown", "markdown", "markdown", "str", "str", "str"], - column_widths= ["5%", None, "7%", "7%", "10%", "10%", "3%", "3%", "3%"], + column_widths= ["5%", None, "7%", "7%", "10%", "10%", "3%", "3%", "34"], interactive=False, col_count=(9, "fixed"), wrap=True,