Python
headless fixes
deepbeepmeepfac265975684
diff --git a/loras/readme.txt b/loras/readme.txtdeleted file mode 100644index 1aedd6a..0000000--- a/loras/readme.txt+++ /dev/null@@ -1 +0,0 @@-folders for loras\ No newline at end of filediff --git a/models/wan/any2video.py b/models/wan/any2video.pyindex 9235f60..b4716e6 100644--- a/models/wan/any2video.py+++ b/models/wan/any2video.py@@ -438,6 +438,21 @@ class WanAny2V:**bbargs):+ model_def = self.model_def+ distill_steps = None+ distill_debug = os.getenv("WAN_DISTILL_DEBUG", "0").lower() not in ("0", "false", "no")+ if model_def is not None and model_def.get("distill_scheduler", False):+ distill_steps = model_def.get("denoising_step_list", None)+ if distill_steps is None:+ raise ValueError("distill_scheduler requires denoising_step_list in model definition")+ sample_solver = "distill"+ sampling_steps = len(distill_steps)+ if model_def.get("sample_shift", None) is not None:+ shift = model_def["sample_shift"]+ if distill_debug:+ print(f"Wan distill scheduler enabled: steps={distill_steps} shift={shift}")++ distill_sigmas = Noneif sample_solver =="euler":# prepare timestepstimesteps = list(np.linspace(self.num_timesteps, 1, sampling_steps, dtype=np.float32))@@ -447,6 +462,19 @@ class WanAny2V:timesteps = [timestep_transform(t, shift=shift, num_timesteps=self.num_timesteps) for t in timesteps][:-1]timesteps = torch.tensor(timesteps)sample_scheduler = None+ elif sample_solver == "distill":+ if distill_steps is None:+ raise ValueError("distill scheduler requires denoising_step_list")+ num_train_timesteps = 1000+ sigmas = torch.linspace(1.0, 0.0, num_train_timesteps + 1, device=self.device)[:-1]+ sigmas = shift * sigmas / (1 + (shift - 1) * sigmas)+ timesteps = sigmas * num_train_timesteps+ denoise_indices = [num_train_timesteps - int(x) for x in distill_steps]+ timesteps = timesteps[denoise_indices].to(self.device)+ distill_sigmas = sigmas[denoise_indices].to("cpu")+ if distill_debug:+ print(f"Wan distill timesteps: {timesteps.tolist()} sigmas: {distill_sigmas.tolist()}")+ sample_scheduler = Noneelif sample_solver == 'causvid':sample_scheduler = FlowMatchScheduler(num_inference_steps=sampling_steps, shift=shift, sigma_min=0, extra_one_step=True)timesteps = torch.tensor([1000, 934, 862, 756, 603, 410, 250, 140, 74])[:sampling_steps].to(self.device)@@ -480,6 +508,8 @@ class WanAny2V:timesteps = sample_scheduler.timestepselse:raise NotImplementedError(f"Unsupported Scheduler {sample_solver}")+ if sample_solver == "distill":+ sampling_steps = len(timesteps)original_timesteps = timestepsseed_g = torch.Generator(device=self.device)@@ -515,7 +545,6 @@ class WanAny2V:if NAG_scale > 1: context = torch.cat([context, context_null], dim=0)# if NAG_scale > 1: context = torch.cat([context, context_NAG], dim=0)if self._interrupt: return None- model_def = self.model_defvace = model_def.get("vace_class", False)phantom = model_type in ["phantom_1.3B", "phantom_14B"]fantasy = model_type in ["fantasy"]@@ -1258,7 +1287,14 @@ class WanAny2V:noise_pred = noise_pred_uncond + guide_scale * (noise_pred_text - noise_pred_uncond)ret_values = noise_pred_uncond = noise_pred_cond = noise_pred_text = neg = None- if sample_solver == "euler":+ if sample_solver == "distill":+ flow_pred = noise_pred[:, :, :target_shape[1]].to(torch.float32)+ sigma = distill_sigmas[i].item()+ latents = latents.to(torch.float32) - sigma * flow_pred+ if i < len(distill_sigmas) - 1:+ sigma_next = distill_sigmas[i + 1].item()+ latents = latents + sigma_next * flow_pred+ elif sample_solver == "euler":dt = timesteps[i] if i == len(timesteps)-1 else (timesteps[i] - timesteps[i + 1])dt = dt.item() / self.num_timestepslatents = latents - noise_pred * dtdiff --git a/models/wan/modules/model.py b/models/wan/modules/model.pyindex 5d302d4..818f672 100644--- a/models/wan/modules/model.py+++ b/models/wan/modules/model.py@@ -909,6 +909,8 @@ class WanModel(ModelMixin, ConfigMixin):if k.startswith(prefix):k = k[len(prefix)+1:]break+ if ".attn2.norm_added_q." in k:+ continueif v.dtype in (torch.float8_e5m2, torch.float8_e4m3fn):for endfix in end_list:if k.endswith(endfix):diff --git a/wgp.py b/wgp.pyindex 69d2806..4bed627 100644--- a/wgp.py+++ b/wgp.py@@ -1188,7 +1188,11 @@ def _load_task_attachments(params, media_base_path, cache_dir=None, log_prefix="# Update params, preserving list/single structureif loaded_items:- params[key] = loaded_items if is_originally_list else loaded_items[0]+ has_pil_item = any(isinstance(item, Image.Image) for item in loaded_items)+ if is_originally_list or has_pil_item:+ params[key] = loaded_items+ else:+ params[key] = loaded_items[0]else:params.pop(key, None)@@ -2380,8 +2384,9 @@ def get_model_filename(model_type, quantization ="int8", dtype_policy = "", moduif len(choices) <= 1:raw_filename = choices[0]else:- if quantization in ("int8", "fp8"):- sub_choices = [ name for name in choices if quantization in os.path.basename(name) or quantization.upper() in os.path.basename(name)]+ if quantization.lower() in ("int8", "fp8", "nvfp4"):+ q = quantization.lower()+ sub_choices = [name for name in choices if q in os.path.basename(name).lower()]else:sub_choices = [ name for name in choices if "quanto" not in os.path.basename(name)]@@ -2563,7 +2568,10 @@ def init_model_def(model_type, model_def):base_model_type = get_base_model_type(model_type)family_handler = model_types_handlers.get(base_model_type, None)if family_handler is None:- raise Exception(f"Unknown model type {base_model_type}")+ if model_def.get("visible", True):+ print(f"Skipping model type '{model_type}' with unsupported architecture '{base_model_type}'.")+ model_def["visible"] = False+ return model_defdefault_model_def = family_handler.query_model_def(base_model_type, model_def)if default_model_def is None: return model_defdefault_model_def.update(model_def)@@ -2982,6 +2990,7 @@ offload.default_verboseLevel = verbose_leveldef check_loras_exist(model_type, loras_choices_files, download = False, send_cmd = None):+ _ensure_loras_url_cache()lora_dir = get_lora_dir(model_type)missing_local_loras = []missing_remote_loras = []@@ -3324,7 +3333,9 @@ def generate_header(model_type, compile, attention_mode):else:header += ", Data Type <B>BF16</B>"- if "int8" in model_filename:+ if "nvfp4" in model_filename.lower():+ header += ", Quantization <B>NVFP4</B>"+ elif "int8" in model_filename:header += ", Quantization <B>Scaled Int8</B>"header += "<FONT></DIV>"@@ -5179,8 +5190,7 @@ def generate_video(if len(errors) > 0: raise Exception(f"Error parsing Extra Transformer Loras: {errors}")loras_selected += extra_loras_transformers- loras = state["loras"]- if len(loras) > 0:+ if len(activated_loras) > 0:loras_list_mult_choices_nums, loras_slists, errors = parse_loras_multipliers(loras_multipliers, len(activated_loras), num_inference_steps, nb_phases = guidance_phases, merge_slist= loras_slists )if len(errors) > 0: raise Exception(f"Error parsing Loras: {errors}")lora_dir = get_lora_dir(model_type)@@ -7471,7 +7481,8 @@ def use_video_settings(state, input_file_list, choice, source):return gr.update(), gr.update(), gr.update(), gr.update()loras_url_cache = Nonedef update_loras_url_cache(lora_dir, loras_selected):- if loras_selected is None: return None+ if loras_selected is None:+ return Noneglobal loras_url_cacheloras_cache_file = "loras_url_cache.json"if loras_url_cache is None:@@ -7500,6 +7511,9 @@ def update_loras_url_cache(lora_dir, loras_selected):return new_loras_selected+def _ensure_loras_url_cache():+ update_loras_url_cache("", [])+def get_settings_from_file(state, file_path, allow_json, merge_with_defaults, switch_type_if_compatible, min_settings_version = 0, merge_loras = None):configs = Noneany_image_or_video = False@@ -10507,6 +10521,9 @@ if __name__ == "__main__":image_save_path = args.output_dirprint(f"Output directory: {args.output_dir}")+ # Headless CLI runs: disable notification sounds to avoid pygame/sounddevice issues.+ server_config["notification_sound_enabled"] = 0+# Create minimal state with all required fieldsstate = {"gen": {