Python
various fixes
DeepBeepMeep4a6a59fc04c6
diff --git a/.gitignore b/.gitignoreindex 6c76284..7fa3fc7 100644--- a/.gitignore+++ b/.gitignore@@ -6,6 +6,8 @@*.gif*.bmp*.mp4+*.webm+*.npy*.mov*.mkv*.logdiff --git a/models/flux/model.py b/models/flux/model.pyindex 74a4f79..78245c4 100644--- a/models/flux/model.py+++ b/models/flux/model.py@@ -317,8 +317,8 @@ class Flux(nn.Module):double_src = ["norm1.linear", "norm1_context.linear", "attn.norm_q", "attn.norm_k", "ff.net.0.proj", "ff.net.2", "ff_context.net.0.proj", "ff_context.net.2", "attn.to_out.0" ,"attn.to_add_out", "attn.to_out", ".attn.to_", ".attn.add_q_proj.", ".attn.add_k_proj.", ".attn.add_v_proj.", ".ff_context.linear_out.", ".ff_context.linear_in.", ".ff.linear_out.", ".ff.linear_in." ]double_tgt = ["img_mod.lin", "txt_mod.lin", "img_attn.norm.query_norm", "img_attn.norm.key_norm", "img_mlp.0", "img_mlp.2", "txt_mlp.0", "txt_mlp.2", "img_attn.proj", "txt_attn.proj", "img_attn.proj", ".img_attn.", ".txt_attn.q.", ".txt_attn.k.", ".txt_attn.v.", ".txt_mlp.2.", ".txt_mlp.0.", ".img_mlp.2.", ".img_mlp.0." ]- single_src = ["norm.linear", "attn.norm_q", "attn.norm_k", "proj_out",".attn.to_q.", ".attn.to_k.", ".attn.to_v.", ".proj_mlp.", ".attn.to_out."]- single_tgt = ["modulation.lin","norm.query_norm", "norm.key_norm", "linear2", ".linear1_attn_q.", ".linear1_attn_k.", ".linear1_attn_v.", ".linear1_mlp.", ".linear2."]+ single_src = ["norm.linear", "attn.norm_q", "attn.norm_k", "proj_out", ".attn.to_qkv_mlp_proj.", ".attn.to_q.", ".attn.to_k.", ".attn.to_v.", ".proj_mlp.", ".attn.to_out."]+ single_tgt = ["modulation.lin","norm.query_norm", "norm.key_norm", "linear2", ".linear1.", ".linear1_attn_q.", ".linear1_attn_k.", ".linear1_attn_v.", ".linear1_mlp.", ".linear2."]for k,v in sd.items():diff --git a/models/flux/modules/layers copy.py b/models/flux/modules/layers copy.pydeleted file mode 100644index e032ea3..0000000--- a/models/flux/modules/layers copy.py+++ /dev/null@@ -1,327 +0,0 @@-import math-from dataclasses import dataclass--import torch-from einops import rearrange-from torch import Tensor, nn--from flux.math import attention, rope--def get_linear_split_map():- hidden_size = 3072- _modules_map = {- "qkv" : {"mapped_modules" : ["q", "k", "v"] , "split_sizes": [hidden_size, hidden_size, hidden_size]},- "linear1" : {"mapped_modules" : ["linear1_attn_q", "linear1_attn_k", "linear1_attn_v", "linear1_mlp"] , "split_sizes": [hidden_size, hidden_size, hidden_size, 7*hidden_size- 3*hidden_size]}- }- return split_linear_modules_map---class EmbedND(nn.Module):- def __init__(self, dim: int, theta: int, axes_dim: list[int]):- super().__init__()- self.dim = dim- self.theta = theta- self.axes_dim = axes_dim-- def forward(self, ids: Tensor) -> Tensor:- n_axes = ids.shape[-1]- emb = torch.cat(- [rope(ids[..., i], self.axes_dim[i], self.theta) for i in range(n_axes)],- dim=-3,- )-- return emb.unsqueeze(1)---def timestep_embedding(t: Tensor, dim, max_period=10000, time_factor: float = 1000.0):- """- Create sinusoidal timestep embeddings.- :param t: a 1-D Tensor of N indices, one per batch element.- These may be fractional.- :param dim: the dimension of the output.- :param max_period: controls the minimum frequency of the embeddings.- :return: an (N, D) Tensor of positional embeddings.- """- t = time_factor * t- half = dim // 2- freqs = torch.exp(-math.log(max_period) * torch.arange(start=0, end=half, dtype=torch.float32) / half).to(- t.device- )-- args = t[:, None].float() * freqs[None]- embedding = torch.cat([torch.cos(args), torch.sin(args)], dim=-1)- if dim % 2:- embedding = torch.cat([embedding, torch.zeros_like(embedding[:, :1])], dim=-1)- if torch.is_floating_point(t):- embedding = embedding.to(t)- return embedding---class MLPEmbedder(nn.Module):- def __init__(self, in_dim: int, hidden_dim: int):- super().__init__()- self.in_layer = nn.Linear(in_dim, hidden_dim, bias=True)- self.silu = nn.SiLU()- self.out_layer = nn.Linear(hidden_dim, hidden_dim, bias=True)-- def forward(self, x: Tensor) -> Tensor:- return self.out_layer(self.silu(self.in_layer(x)))---class RMSNorm(torch.nn.Module):- def __init__(self, dim: int):- super().__init__()- self.scale = nn.Parameter(torch.ones(dim))-- def forward(self, x: Tensor):- x_dtype = x.dtype- x = x.float()- rrms = torch.rsqrt(torch.mean(x**2, dim=-1, keepdim=True) + 1e-6)- return (x * rrms).to(dtype=x_dtype) * self.scale---class QKNorm(torch.nn.Module):- def __init__(self, dim: int):- super().__init__()- self.query_norm = RMSNorm(dim)- self.key_norm = RMSNorm(dim)-- def forward(self, q: Tensor, k: Tensor, v: Tensor) -> tuple[Tensor, Tensor]:- q = self.query_norm(q)- k = self.key_norm(k)- return q.to(v), k.to(v)---class SelfAttention(nn.Module):- def __init__(self, dim: int, num_heads: int = 8, qkv_bias: bool = False):- super().__init__()- self.num_heads = num_heads- head_dim = dim // num_heads-- self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)- self.norm = QKNorm(head_dim)- self.proj = nn.Linear(dim, dim)-- def forward(self, x: Tensor, pe: Tensor) -> Tensor:- qkv = self.qkv(x)- q, k, v = rearrange(qkv, "B L (K H D) -> K B H L D", K=3, H=self.num_heads)- q, k = self.norm(q, k, v)- x = attention(q, k, v, pe=pe)- x = self.proj(x)- return x---@dataclass-class ModulationOut:- shift: Tensor- scale: Tensor- gate: Tensor---class Modulation(nn.Module):- def __init__(self, dim: int, double: bool):- super().__init__()- self.is_double = double- self.multiplier = 6 if double else 3- self.lin = nn.Linear(dim, self.multiplier * dim, bias=True)-- def forward(self, vec: Tensor) -> tuple[ModulationOut, ModulationOut | None]:- out = self.lin(nn.functional.silu(vec))[:, None, :].chunk(self.multiplier, dim=-1)-- return (- ModulationOut(*out[:3]),- ModulationOut(*out[3:]) if self.is_double else None,- )---class DoubleStreamBlock(nn.Module):- def __init__(self, hidden_size: int, num_heads: int, mlp_ratio: float, qkv_bias: bool = False):- super().__init__()-- mlp_hidden_dim = int(hidden_size * mlp_ratio)- self.num_heads = num_heads- self.hidden_size = hidden_size- self.img_mod = Modulation(hidden_size, double=True)- self.img_norm1 = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)- self.img_attn = SelfAttention(dim=hidden_size, num_heads=num_heads, qkv_bias=qkv_bias)-- self.img_norm2 = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)- self.img_mlp = nn.Sequential(- nn.Linear(hidden_size, mlp_hidden_dim, bias=True),- nn.GELU(approximate="tanh"),- nn.Linear(mlp_hidden_dim, hidden_size, bias=True),- )-- self.txt_mod = Modulation(hidden_size, double=True)- self.txt_norm1 = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)- self.txt_attn = SelfAttention(dim=hidden_size, num_heads=num_heads, qkv_bias=qkv_bias)-- self.txt_norm2 = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)- self.txt_mlp = nn.Sequential(- nn.Linear(hidden_size, mlp_hidden_dim, bias=True),- nn.GELU(approximate="tanh"),- nn.Linear(mlp_hidden_dim, hidden_size, bias=True),- )-- def forward(self, img: Tensor, txt: Tensor, vec: Tensor, pe: Tensor) -> tuple[Tensor, Tensor]:- img_mod1, img_mod2 = self.img_mod(vec)- txt_mod1, txt_mod2 = self.txt_mod(vec)-- # prepare image for attention- img_modulated = self.img_norm1(img)- img_modulated.mul_(1 + img_mod1.scale)- img_modulated.add_(img_mod1.shift)-- shape = (*img_modulated.shape[:2], self.num_heads, int(img_modulated.shape[-1] / self.num_heads) )- img_q = self.img_attn.q(img_modulated).view(*shape).transpose(1,2)- img_k = self.img_attn.k(img_modulated).view(*shape).transpose(1,2)- img_v = self.img_attn.v(img_modulated).view(*shape).transpose(1,2)- del img_modulated-- # img_qkv = self.img_attn.qkv(img_modulated)- # img_q, img_k, img_v = rearrange(img_qkv, "B L (K H D) -> K B H L D", K=3, H=self.num_heads)-- img_q, img_k = self.img_attn.norm(img_q, img_k, img_v)-- # prepare txt for attention- txt_modulated = self.txt_norm1(txt)- txt_modulated.mul_(1 + txt_mod1.scale)- txt_modulated.add_(txt_mod1.shift)- # txt_modulated = (1 + txt_mod1.scale) * txt_modulated + txt_mod1.shift-- shape = (*txt_modulated.shape[:2], self.num_heads, int(txt_modulated.shape[-1] / self.num_heads) )- txt_q = self.txt_attn.q(txt_modulated).view(*shape).transpose(1,2)- txt_k = self.txt_attn.k(txt_modulated).view(*shape).transpose(1,2)- txt_v = self.txt_attn.v(txt_modulated).view(*shape).transpose(1,2)- del txt_modulated-- # txt_qkv = self.txt_attn.qkv(txt_modulated)- # txt_q, txt_k, txt_v = rearrange(txt_qkv, "B L (K H D) -> K B H L D", K=3, H=self.num_heads)-- txt_q, txt_k = self.txt_attn.norm(txt_q, txt_k, txt_v)-- # run actual attention- q = torch.cat((txt_q, img_q), dim=2)- k = torch.cat((txt_k, img_k), dim=2)- v = torch.cat((txt_v, img_v), dim=2)-- qkv_list = [q, k, v]- del q, k, v- attn = attention(qkv_list, pe=pe)-- txt_attn, img_attn = attn[:, : txt.shape[1]], attn[:, txt.shape[1] :]-- # calculate the img blocks- img.addcmul_(self.img_attn.proj(img_attn), img_mod1.gate)- img.addcmul_(self.img_mlp((1 + img_mod2.scale) * self.img_norm2(img) + img_mod2.shift), img_mod2.gate)-- # img = img + img_mod1.gate * self.img_attn.proj(img_attn)- # img = img + img_mod2.gate * self.img_mlp((1 + img_mod2.scale) * self.img_norm2(img) + img_mod2.shift)-- # calculate the txt blocks- txt.addcmul_(self.txt_attn.proj(txt_attn), txt_mod1.gate)- txt.addcmul_(self.txt_mlp((1 + txt_mod2.scale) * self.txt_norm2(txt) + txt_mod2.shift), txt_mod2.gate)- # txt = txt + txt_mod1.gate * self.txt_attn.proj(txt_attn)- # txt = txt + txt_mod2.gate * self.txt_mlp((1 + txt_mod2.scale) * self.txt_norm2(txt) + txt_mod2.shift)- return img, txt---class SingleStreamBlock(nn.Module):- """- A DiT block with parallel linear layers as described in- https://arxiv.org/abs/2302.05442 and adapted modulation interface.- """-- def __init__(- self,- hidden_size: int,- num_heads: int,- mlp_ratio: float = 4.0,- qk_scale: float | None = None,- ):- super().__init__()- self.hidden_dim = hidden_size- self.num_heads = num_heads- head_dim = hidden_size // num_heads- self.scale = qk_scale or head_dim**-0.5-- self.mlp_hidden_dim = int(hidden_size * mlp_ratio)- # qkv and mlp_in- self.linear1 = nn.Linear(hidden_size, hidden_size * 3 + self.mlp_hidden_dim)- # proj and mlp_out- self.linear2 = nn.Linear(hidden_size + self.mlp_hidden_dim, hidden_size)-- self.norm = QKNorm(head_dim)-- self.hidden_size = hidden_size- self.pre_norm = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)-- self.mlp_act = nn.GELU(approximate="tanh")- self.modulation = Modulation(hidden_size, double=False)-- def forward(self, x: Tensor, vec: Tensor, pe: Tensor) -> Tensor:- mod, _ = self.modulation(vec)- x_mod = self.pre_norm(x)- x_mod.mul_(1 + mod.scale)- x_mod.add_(mod.shift)-- ##### More spagheti VRAM optimizations done by DeepBeepMeep !- # I am sure you are a nice person and as you copy this code, you will give me proper credits:- # Please link to https://github.com/deepbeepmeep/Wan2GP and @deepbeepmeep on twitter-- # x_mod = (1 + mod.scale) * x + mod.shift-- shape = (*x_mod.shape[:2], self.num_heads, int(x_mod.shape[-1] / self.num_heads) )- q = self.linear1_attn_q(x_mod).view(*shape).transpose(1,2)- k = self.linear1_attn_k(x_mod).view(*shape).transpose(1,2)- v = self.linear1_attn_v(x_mod).view(*shape).transpose(1,2)-- # shape = (*txt_mod.shape[:2], self.heads_num, int(txt_mod.shape[-1] / self.heads_num) )- # txt_q = self.linear1_attn_q(txt_mod).view(*shape)- # txt_k = self.linear1_attn_k(txt_mod).view(*shape)- # txt_v = self.linear1_attn_v(txt_mod).view(*shape)-- # qkv, mlp = torch.split(self.linear1(x_mod), [3 * self.hidden_size, self.mlp_hidden_dim], dim=-1)-- # q, k, v = rearrange(qkv, "B L (K H D) -> K B H L D", K=3, H=self.num_heads)- q, k = self.norm(q, k, v)-- # compute attention- qkv_list = [q, k, v]- del q, k, v- attn = attention(qkv_list, pe=pe)- # compute activation in mlp stream, cat again and run second linear layer-- x_mod_shape = x_mod.shape- x_mod = x_mod.view(-1, x_mod.shape[-1])- chunk_size = int(x_mod_shape[1]/6)- x_chunks = torch.split(x_mod, chunk_size)- attn = attn.view(-1, attn.shape[-1])- attn_chunks =torch.split(attn, chunk_size)- for x_chunk, attn_chunk in zip(x_chunks, attn_chunks):- mlp_chunk = self.linear1_mlp(x_chunk)- mlp_chunk = self.mlp_act(mlp_chunk)- attn_mlp_chunk = torch.cat((attn_chunk, mlp_chunk), -1)- del attn_chunk, mlp_chunk- x_chunk[...] = self.linear2(attn_mlp_chunk)- del attn_mlp_chunk- x_mod = x_mod.view(x_mod_shape)- x.addcmul_(x_mod, mod.gate)- return x-- # output = self.linear2(torch.cat((attn, self.mlp_act(mlp)), 2))- # return x + mod.gate * output---class LastLayer(nn.Module):- def __init__(self, hidden_size: int, patch_size: int, out_channels: int):- super().__init__()- self.norm_final = nn.LayerNorm(hidden_size, elementwise_affine=False, eps=1e-6)- self.linear = nn.Linear(hidden_size, patch_size * patch_size * out_channels, bias=True)- self.adaLN_modulation = nn.Sequential(nn.SiLU(), nn.Linear(hidden_size, 2 * hidden_size, bias=True))-- def forward(self, x: Tensor, vec: Tensor) -> Tensor:- shift, scale = self.adaLN_modulation(vec).chunk(2, dim=1)- x = (1 + scale[:, None, :]) * self.norm_final(x) + shift[:, None, :]- x = self.linear(x)- return xdiff --git a/models/wan/wan_handler.py b/models/wan/wan_handler.pyindex e31c54b..63d604d 100644--- a/models/wan/wan_handler.py+++ b/models/wan/wan_handler.py@@ -215,6 +215,9 @@ class family_handler():if base_model_type in ["vace_multitalk_14B", "vace_standin_14B", "vace_lynx_14B"]:extra_model_def["parent_model_type"] = "vace_14B"+ if base_model_type in ["alpha2"]:+ extra_model_def["parent_model_type"] = "alpha"+group = "wan"if base_model_type in ["t2v_2_2", "vace_14B_2_2"] or test_i2v_2_2(base_model_type):profiles_dir = "wan_2_2"diff --git a/plugins/wan2gp-configuration/plugin.py b/plugins/wan2gp-configuration/plugin.pyindex 1258e06..d071e76 100644--- a/plugins/wan2gp-configuration/plugin.py+++ b/plugins/wan2gp-configuration/plugin.py@@ -129,6 +129,12 @@ class ConfigTabPlugin(WAN2GPPlugin):value=self.server_config.get("loras_root", "loras"),interactive=not self.args.lock_config)+ self.save_queue_if_crash_choice = gr.Dropdown(+ choices=[("Disabled", 0), ("Overwrite Last Error Queue", 1), ("Create a New Error Queue File", 2)],+ value=self.server_config.get("save_queue_if_crash", 1),+ label="Save Queue if Crash during Generation",+ interactive=not self.args.lock_config+ )self.UI_theme_choice = gr.Dropdown(choices=[("Blue Sky (Default)", "default"), ("Classic Gradio", "gradio")],value=self.server_config.get("UI_theme", "default"), label="UI Theme (requires restart)"@@ -282,7 +288,7 @@ class ConfigTabPlugin(WAN2GPPlugin):self.state,self.transformer_types_choices, self.model_hierarchy_type_choice, self.fit_canvas_choice,self.attention_choice, self.preload_model_policy_choice, self.clear_file_list_choice,- self.display_stats_choice, self.max_frames_multiplier_choice, self.enable_4k_resolutions_choice, self.checkpoints_paths_choice, self.loras_root_choice,+ self.display_stats_choice, self.max_frames_multiplier_choice, self.enable_4k_resolutions_choice, self.checkpoints_paths_choice, self.loras_root_choice, self.save_queue_if_crash_choice,self.UI_theme_choice, self.queue_color_scheme_choice,self.quantization_choice, self.transformer_dtype_policy_choice, self.mixed_precision_choice,self.text_encoder_quantization_choice, self.lm_decoder_engine_choice, self.VAE_precision_choice, self.compile_choice,@@ -334,7 +340,7 @@ class ConfigTabPlugin(WAN2GPPlugin):(transformer_types_choices, model_hierarchy_type_choice, fit_canvas_choice,attention_choice, preload_model_policy_choice, clear_file_list_choice,- display_stats_choice, max_frames_multiplier_choice, enable_4k_resolutions_choice, checkpoints_paths_choice, loras_root_choice,+ display_stats_choice, max_frames_multiplier_choice, enable_4k_resolutions_choice, checkpoints_paths_choice, loras_root_choice, save_queue_if_crash_choice,UI_theme_choice, queue_color_scheme_choice,quantization_choice, transformer_dtype_policy_choice, mixed_precision_choice,text_encoder_quantization_choice, lm_decoder_engine_choice, VAE_precision_choice, compile_choice,@@ -391,6 +397,7 @@ class ConfigTabPlugin(WAN2GPPlugin):"model_hierarchy_type": model_hierarchy_type_choice,"checkpoints_paths": checkpoints_paths,"loras_root": loras_root_choice,+ "save_queue_if_crash": save_queue_if_crash_choice,"queue_color_scheme": queue_color_scheme_choice,"embed_source_images": embed_source_images_choice,"video_container": "mp4", # Fixed to MP4@@ -420,7 +427,7 @@ class ConfigTabPlugin(WAN2GPPlugin):"mmaudio_persistence", "mmaudio_enabled", "rife_version","prompt_enhancer_temperature", "prompt_enhancer_top_p", "prompt_enhancer_randomize_seed","max_frames_multiplier", "display_stats", "enable_4k_resolutions", "max_reserved_loras", "video_output_codec", "video_container",- "embed_source_images", "image_output_codec", "audio_output_codec", "audio_stand_alone_output_codec", "checkpoints_paths", "loras_root",+ "embed_source_images", "image_output_codec", "audio_output_codec", "audio_stand_alone_output_codec", "checkpoints_paths", "loras_root", "save_queue_if_crash","model_hierarchy_type", "UI_theme", "queue_color_scheme"]diff --git a/shared/ffmpeg_setup.py b/shared/ffmpeg_setup.pyindex 5655f61..c5c7928 100644--- a/shared/ffmpeg_setup.py+++ b/shared/ffmpeg_setup.py@@ -29,6 +29,34 @@ def download_ffmpeg(bin_directory: typing.Optional[typing.Union[str, Path]] = Nobin_dir.mkdir(parents=True, exist_ok=True)repo_root = bin_dir.parent+ def _candidate_name(name: str) -> str:+ if os.name == "nt" and not name.endswith(".exe"):+ return f"{name}.exe"+ return name++ def _quarantine_root_ffmpeg():+ root_ffmpeg = repo_root / _candidate_name("ffmpeg")+ if not root_ffmpeg.is_file():+ return+ quarantine_dir = repo_root / "ffmpeg_quarantine"+ quarantine_dir.mkdir(parents=True, exist_ok=True)+ target_path = quarantine_dir / root_ffmpeg.name+ if target_path.exists():+ stem = target_path.stem+ suffix = target_path.suffix+ idx = 1+ while True:+ candidate = quarantine_dir / f"{stem}_{idx}{suffix}"+ if not candidate.exists():+ target_path = candidate+ break+ idx += 1+ shutil.move(str(root_ffmpeg), str(target_path))+ print(+ f"[FFmpeg] Quarantined root binary: {root_ffmpeg} -> {target_path}. "+ "Reason: ffmpeg.exe in the project root can be picked from CWD and break TorchCodec DLL loading on Windows. Quarantined file can be deleted if unused."+ )+def _ensure_bin_dir_on_path():current_path = os.environ.get("PATH", "")path_parts = current_path.split(os.pathsep) if current_path else []@@ -56,14 +84,10 @@ def download_ffmpeg(bin_directory: typing.Optional[typing.Union[str, Path]] = Noif str(bin_dir) not in ld_parts:os.environ["LD_LIBRARY_PATH"] = os.pathsep.join([str(bin_dir)] + ld_parts) if current_ld else str(bin_dir)+ _quarantine_root_ffmpeg()_ensure_bin_dir_on_path()_ensure_library_path()- def _candidate_name(name: str) -> str:- if os.name == "nt" and not name.endswith(".exe"):- return f"{name}.exe"- return name-def _resolve_path(name: str) -> typing.Optional[Path]:# Check ffmpeg_bins folder firstcandidate = bin_dir / _candidate_name(name)diff --git a/wgp.py b/wgp.pyindex db2fc85..115c9aa 100644--- a/wgp.py+++ b/wgp.py@@ -92,7 +92,7 @@ AUTOSAVE_TEMPLATE_PATH = AUTOSAVE_FILENAMECONFIG_FILENAME = "wgp_config.json"PROMPT_VARS_MAX = 10target_mmgp_version = "3.7.4"-WanGP_version = "10.80"+WanGP_version = "10.81"settings_version = 2.50max_source_video_frames = 3000prompt_enhancer_image_caption_model, prompt_enhancer_image_caption_processor, prompt_enhancer_llm_model, prompt_enhancer_llm_tokenizer = None, None, None, None@@ -2347,6 +2347,7 @@ if not Path(config_load_filename).is_file():"UI_theme": "default","checkpoints_paths": fl.default_checkpoints_paths,"loras_root": DEFAULT_LORA_ROOT,+ "save_queue_if_crash": 1,"queue_color_scheme": "pastel","model_hierarchy_type": 1,"mmaudio_mode": 0,@@ -2976,6 +2977,7 @@ if not "audio_output_codec" in server_config: server_config["audio_output_codec"if not "audio_stand_alone_output_codec" in server_config: server_config["audio_stand_alone_output_codec"]= "wav"if not "rife_version" in server_config: server_config["rife_version"] = "v4"if "loras_root" not in server_config: server_config["loras_root"] = DEFAULT_LORA_ROOT+if "save_queue_if_crash" not in server_config: server_config["save_queue_if_crash"] = 1if "prompt_enhancer_temperature" not in server_config: server_config["prompt_enhancer_temperature"] = 0.6if "prompt_enhancer_top_p" not in server_config: server_config["prompt_enhancer_top_p"] = 0.9if "prompt_enhancer_randomize_seed" not in server_config: server_config["prompt_enhancer_randomize_seed"] = True@@ -7136,12 +7138,14 @@ def process_tasks(state):elif cmd == "error":queue.clear()try:- error_filename = get_available_filename("", AUTOSAVE_ERROR_FILENAME)- if _save_queue_to_zip(global_queue_ref, error_filename):- print(f"Error Queue autosaved successfully to {error_filename}")- gr.Info(f"Error Queue autosaved successfully to {error_filename}")- else:- print("Autosave Error Queue failed.")+ save_queue_if_crash = server_config.get("save_queue_if_crash", 1)+ if save_queue_if_crash:+ error_filename = AUTOSAVE_ERROR_FILENAME if save_queue_if_crash == 1 else get_available_filename("", AUTOSAVE_ERROR_FILENAME, f"_{datetime.now():%Y%m%d_%H%M%S}")+ if _save_queue_to_zip(global_queue_ref, error_filename):+ print(f"Error Queue autosaved successfully to {error_filename}")+ gr.Info(f"Error Queue autosaved successfully to {error_filename}")+ else:+ print("Autosave Error Queue failed.")except Exception as e:print(f"Error during autosave: {e}")update_global_queue_ref(queue)