Skip to content
Python

added VAE spatial upsampler

DeepBeepMeepbdfa6b272409
diff --git a/README.md b/README.md
index bb60662..2a26455 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,10 @@ WanGP supports the Wan (and derived models), Hunyuan Video and LTV Video models
-----
## 🔥 Latest Updates :
+### November 8 2025: WanGP v9.4, Free Lunch
+
+**VAE Upsampler** for Wan 2.1/2.2 Text 2 Image and Qwen Image: *spacepxl* has tweaked the VAE Decoder used by *Wan* & *Qwen* so that it can decode and upsample x2 at the same time. The end Result is a Fast High Quality Image Upsampler (much better than Lanczos). Check the *Postprocessing Tab* / *Spatial Upsampling* Dropdown box. Unfortunately this will work only with Image Generation, no support yet for Video Generation. I have also added a VAE Refiner that keeps the existing resolution but slightly improves the details.
+
### November 6 2025: WanGP v9.35, How many bananas are too many bananas ?
**Chrono Edit**: a new original way to edit an Image. This one will generate a Video will that performs the full edition work and return the last Image. It can be hit or a miss but when it works it is quite impressive. Please note you must absolutely use the *Prompt Enhancer* on your *Prompt Instruction* because this model expects a very specific format. The Prompt Enhancer for this model has a specific System Prompt to generate the right Chrono Edit Prompt.
diff --git a/models/qwen/autoencoder_kl_qwenimage.py b/models/qwen/autoencoder_kl_qwenimage.py
index d144284..026a2f4 100644
--- a/models/qwen/autoencoder_kl_qwenimage.py
+++ b/models/qwen/autoencoder_kl_qwenimage.py
@@ -571,6 +571,7 @@ class QwenImageDecoder3d(nn.Module):
attn_scales=[],
temperal_upsample=[False, True, True],
dropout=0.0,
+ upsampler_factor = 1,
non_linearity: str = "silu",
):
super().__init__()
@@ -580,7 +581,7 @@ class QwenImageDecoder3d(nn.Module):
self.num_res_blocks = num_res_blocks
self.attn_scales = attn_scales
self.temperal_upsample = temperal_upsample
-
+ self.upsampler_factor = upsampler_factor
self.nonlinearity = get_activation(non_linearity)
# dimensions
@@ -622,7 +623,7 @@ class QwenImageDecoder3d(nn.Module):
# output blocks
self.norm_out = QwenImageRMS_norm(out_dim, images=False)
- self.conv_out = QwenImageCausalConv3d(out_dim, 3, 3, padding=1)
+ self.conv_out = QwenImageCausalConv3d(out_dim, 3*int(upsampler_factor*upsampler_factor), 3, padding=1)
self.gradient_checkpointing = False
@@ -661,6 +662,12 @@ class QwenImageDecoder3d(nn.Module):
feat_idx[0] += 1
else:
x = self.conv_out(x)
+
+
+ if self.upsampler_factor > 1:
+ x = F.pixel_shuffle(x.movedim(2, 1), upscale_factor=self.upsampler_factor).movedim(1, 2) # pixel shuffle needs [..., C, H, W] format
+
+
return x
@@ -711,6 +718,7 @@ class AutoencoderKLQwenImage(ModelMixin, ConfigMixin, FromOriginalModelMixin):
attn_scales: List[float] = [],
temperal_downsample: List[bool] = [False, True, True],
dropout: float = 0.0,
+ upsampler_factor = 1,
latents_mean: List[float] = [-0.7571, -0.7089, -0.9113, 0.1075, -0.1745, 0.9653, -0.1517, 1.5508, 0.4134, -0.0715, 0.5517, -0.3632, -0.1922, -0.9497, 0.2503, -0.2921],
latents_std: List[float] = [2.8184, 1.4541, 2.3275, 2.6558, 1.2196, 1.7708, 2.6052, 2.0743, 3.2687, 2.1526, 2.8652, 1.5579, 1.6382, 1.1253, 2.8251, 1.9160],
) -> None:
@@ -720,7 +728,7 @@ class AutoencoderKLQwenImage(ModelMixin, ConfigMixin, FromOriginalModelMixin):
self.z_dim = z_dim
self.temperal_downsample = temperal_downsample
self.temperal_upsample = temperal_downsample[::-1]
-
+ self.upsampler_factor = upsampler_factor
self.encoder = QwenImageEncoder3d(
base_dim, z_dim * 2, dim_mult, num_res_blocks, attn_scales, self.temperal_downsample, dropout
)
@@ -728,7 +736,7 @@ class AutoencoderKLQwenImage(ModelMixin, ConfigMixin, FromOriginalModelMixin):
self.post_quant_conv = QwenImageCausalConv3d(z_dim, z_dim, 1)
self.decoder = QwenImageDecoder3d(
- base_dim, z_dim, dim_mult, num_res_blocks, attn_scales, self.temperal_upsample, dropout
+ base_dim, z_dim, dim_mult, num_res_blocks, attn_scales, self.temperal_upsample, dropout, upsampler_factor
)
self.spatial_compression_ratio = 2 ** len(self.temperal_downsample)
@@ -1025,16 +1033,18 @@ class AutoencoderKLQwenImage(ModelMixin, ConfigMixin, FromOriginalModelMixin):
returned.
"""
_, _, num_frames, height, width = z.shape
- sample_height = height * self.spatial_compression_ratio
- sample_width = width * self.spatial_compression_ratio
+ factor = self.upsampler_factor
+ sample_height = height * self.spatial_compression_ratio * factor
+ sample_width = width * self.spatial_compression_ratio * factor
tile_latent_min_height = self.tile_sample_min_height // self.spatial_compression_ratio
tile_latent_min_width = self.tile_sample_min_width // self.spatial_compression_ratio
tile_latent_stride_height = self.tile_sample_stride_height // self.spatial_compression_ratio
tile_latent_stride_width = self.tile_sample_stride_width // self.spatial_compression_ratio
-
- blend_height = self.tile_sample_min_height - self.tile_sample_stride_height
- blend_width = self.tile_sample_min_width - self.tile_sample_stride_width
+ tile_sample_min_height, tile_sample_stride_height = self.tile_sample_min_height * factor , self.tile_sample_stride_height * factor
+ tile_sample_min_width, tile_sample_stride_width = self.tile_sample_min_width * factor , self.tile_sample_stride_width * factor
+ blend_height = tile_sample_min_height - tile_sample_stride_height
+ blend_width = tile_sample_min_width - tile_sample_stride_width
# Split z into overlapping tiles and decode them separately.
# The tiles have an overlap to avoid seams between tiles.
@@ -1064,7 +1074,7 @@ class AutoencoderKLQwenImage(ModelMixin, ConfigMixin, FromOriginalModelMixin):
tile = self.blend_v(rows[i - 1][j], tile, blend_height)
if j > 0:
tile = self.blend_h(row[j - 1], tile, blend_width)
- result_row.append(tile[:, :, :, : self.tile_sample_stride_height, : self.tile_sample_stride_width])
+ result_row.append(tile[:, :, :, : tile_sample_stride_height, : tile_sample_stride_width])
result_rows.append(torch.cat(result_row, dim=-1))
dec = torch.cat(result_rows, dim=3)[:, :, :, :sample_height, :sample_width]
diff --git a/models/qwen/convert_diffusers_qwen_vae.py b/models/qwen/convert_diffusers_qwen_vae.py
new file mode 100644
index 0000000..1575026
--- /dev/null
+++ b/models/qwen/convert_diffusers_qwen_vae.py
@@ -0,0 +1,207 @@
+
+from typing import Mapping, Dict
+import torch
+
+def convert_state_dict(state_dict: Mapping[str, torch.Tensor]) -> Dict[str, torch.Tensor]:
+ """
+ Convert a ComfyUI-formatted Wan/Qwen VAE state_dict to Diffusers format.
+
+ Input: dict-like mapping from str -> torch.Tensor (e.g. loaded from safetensors)
+ Output: new dict with Diffusers key names (no mutation of the input)
+ """
+
+ # Exact key remaps for middle resnets (encoder/decoder)
+ middle_key_mapping = {
+ # Encoder middle resnets
+ "encoder.middle.0.residual.0.gamma": "encoder.mid_block.resnets.0.norm1.gamma",
+ "encoder.middle.0.residual.2.bias": "encoder.mid_block.resnets.0.conv1.bias",
+ "encoder.middle.0.residual.2.weight": "encoder.mid_block.resnets.0.conv1.weight",
+ "encoder.middle.0.residual.3.gamma": "encoder.mid_block.resnets.0.norm2.gamma",
+ "encoder.middle.0.residual.6.bias": "encoder.mid_block.resnets.0.conv2.bias",
+ "encoder.middle.0.residual.6.weight": "encoder.mid_block.resnets.0.conv2.weight",
+
+ "encoder.middle.2.residual.0.gamma": "encoder.mid_block.resnets.1.norm1.gamma",
+ "encoder.middle.2.residual.2.bias": "encoder.mid_block.resnets.1.conv1.bias",
+ "encoder.middle.2.residual.2.weight": "encoder.mid_block.resnets.1.conv1.weight",
+ "encoder.middle.2.residual.3.gamma": "encoder.mid_block.resnets.1.norm2.gamma",
+ "encoder.middle.2.residual.6.bias": "encoder.mid_block.resnets.1.conv2.bias",
+ "encoder.middle.2.residual.6.weight": "encoder.mid_block.resnets.1.conv2.weight",
+
+ # Decoder middle resnets
+ "decoder.middle.0.residual.0.gamma": "decoder.mid_block.resnets.0.norm1.gamma",
+ "decoder.middle.0.residual.2.bias": "decoder.mid_block.resnets.0.conv1.bias",
+ "decoder.middle.0.residual.2.weight": "decoder.mid_block.resnets.0.conv1.weight",
+ "decoder.middle.0.residual.3.gamma": "decoder.mid_block.resnets.0.norm2.gamma",
+ "decoder.middle.0.residual.6.bias": "decoder.mid_block.resnets.0.conv2.bias",
+ "decoder.middle.0.residual.6.weight": "decoder.mid_block.resnets.0.conv2.weight",
+
+ "decoder.middle.2.residual.0.gamma": "decoder.mid_block.resnets.1.norm1.gamma",
+ "decoder.middle.2.residual.2.bias": "decoder.mid_block.resnets.1.conv1.bias",
+ "decoder.middle.2.residual.2.weight": "decoder.mid_block.resnets.1.conv1.weight",
+ "decoder.middle.2.residual.3.gamma": "decoder.mid_block.resnets.1.norm2.gamma",
+ "decoder.middle.2.residual.6.bias": "decoder.mid_block.resnets.1.conv2.bias",
+ "decoder.middle.2.residual.6.weight": "decoder.mid_block.resnets.1.conv2.weight",
+ }
+
+ # Exact key remaps for the mid attention blocks (encoder/decoder)
+ attention_mapping = {
+ "encoder.middle.1.norm.gamma": "encoder.mid_block.attentions.0.norm.gamma",
+ "encoder.middle.1.to_qkv.weight": "encoder.mid_block.attentions.0.to_qkv.weight",
+ "encoder.middle.1.to_qkv.bias": "encoder.mid_block.attentions.0.to_qkv.bias",
+ "encoder.middle.1.proj.weight": "encoder.mid_block.attentions.0.proj.weight",
+ "encoder.middle.1.proj.bias": "encoder.mid_block.attentions.0.proj.bias",
+
+ "decoder.middle.1.norm.gamma": "decoder.mid_block.attentions.0.norm.gamma",
+ "decoder.middle.1.to_qkv.weight": "decoder.mid_block.attentions.0.to_qkv.weight",
+ "decoder.middle.1.to_qkv.bias": "decoder.mid_block.attentions.0.to_qkv.bias",
+ "decoder.middle.1.proj.weight": "decoder.mid_block.attentions.0.proj.weight",
+ "decoder.middle.1.proj.bias": "decoder.mid_block.attentions.0.proj.bias",
+ }
+
+ # Heads (norm_out / conv_out) for encoder/decoder
+ head_mapping = {
+ "encoder.head.0.gamma": "encoder.norm_out.gamma",
+ "encoder.head.2.bias": "encoder.conv_out.bias",
+ "encoder.head.2.weight": "encoder.conv_out.weight",
+
+ "decoder.head.0.gamma": "decoder.norm_out.gamma",
+ "decoder.head.2.bias": "decoder.conv_out.bias",
+ "decoder.head.2.weight": "decoder.conv_out.weight",
+ }
+
+ # Latent quantization bridges
+ quant_mapping = {
+ "conv1.weight": "quant_conv.weight",
+ "conv1.bias": "quant_conv.bias",
+ "conv2.weight": "post_quant_conv.weight",
+ "conv2.bias": "post_quant_conv.bias",
+ }
+
+ out: Dict[str, torch.Tensor] = {}
+
+ for key, value in state_dict.items():
+ # 1) Direct dictionary remaps
+ if key in middle_key_mapping:
+ out[middle_key_mapping[key]] = value
+ continue
+ if key in attention_mapping:
+ out[attention_mapping[key]] = value
+ continue
+ if key in head_mapping:
+ out[head_mapping[key]] = value
+ continue
+ if key in quant_mapping:
+ out[quant_mapping[key]] = value
+ continue
+
+ # 2) Conv-in aliases for encoder/decoder
+ if key == "encoder.conv1.weight":
+ out["encoder.conv_in.weight"] = value
+ continue
+ if key == "encoder.conv1.bias":
+ out["encoder.conv_in.bias"] = value
+ continue
+ if key == "decoder.conv1.weight":
+ out["decoder.conv_in.weight"] = value
+ continue
+ if key == "decoder.conv1.bias":
+ out["decoder.conv_in.bias"] = value
+ continue
+
+ # 3) Encoder down path (downsamples.* -> down_blocks.*)
+ if key.startswith("encoder.downsamples."):
+ new_key = key.replace("encoder.downsamples.", "encoder.down_blocks.")
+
+ # Residual -> (norm1/conv1/norm2/conv2), shortcut passthrough
+ if ".residual.0.gamma" in new_key:
+ new_key = new_key.replace(".residual.0.gamma", ".norm1.gamma")
+ elif ".residual.2.bias" in new_key:
+ new_key = new_key.replace(".residual.2.bias", ".conv1.bias")
+ elif ".residual.2.weight" in new_key:
+ new_key = new_key.replace(".residual.2.weight", ".conv1.weight")
+ elif ".residual.3.gamma" in new_key:
+ new_key = new_key.replace(".residual.3.gamma", ".norm2.gamma")
+ elif ".residual.6.bias" in new_key:
+ new_key = new_key.replace(".residual.6.bias", ".conv2.bias")
+ elif ".residual.6.weight" in new_key:
+ new_key = new_key.replace(".residual.6.weight", ".conv2.weight")
+ elif ".shortcut.bias" in new_key:
+ new_key = new_key.replace(".shortcut.bias", ".conv_shortcut.bias")
+ elif ".shortcut.weight" in new_key:
+ new_key = new_key.replace(".shortcut.weight", ".conv_shortcut.weight")
+
+ out[new_key] = value
+ continue
+
+ # 4) Decoder up path (upsamples.* -> up_blocks.*)
+ if key.startswith("decoder.upsamples."):
+ parts = key.split(".")
+ # format: decoder.upsamples.{block_idx}.(residual|resample|time_conv|shortcut)...
+ if len(parts) >= 3 and parts[2].isdigit():
+ block_idx = int(parts[2])
+
+ # 4a) Residual groups: map flat indices -> (up_block_id, resnet_id)
+ if "residual" in key:
+ if block_idx in (0, 1, 2):
+ up_block_id, resnet_id = 0, block_idx
+ elif block_idx in (4, 5, 6):
+ up_block_id, resnet_id = 1, block_idx - 4
+ elif block_idx in (8, 9, 10):
+ up_block_id, resnet_id = 2, block_idx - 8
+ elif block_idx in (12, 13, 14):
+ up_block_id, resnet_id = 3, block_idx - 12
+ else:
+ # keep unmapped residuals as-is
+ out[key] = value
+ continue
+
+ if ".residual.0.gamma" in key:
+ new_key = f"decoder.up_blocks.{up_block_id}.resnets.{resnet_id}.norm1.gamma"
+ elif ".residual.2.bias" in key:
+ new_key = f"decoder.up_blocks.{up_block_id}.resnets.{resnet_id}.conv1.bias"
+ elif ".residual.2.weight" in key:
+ new_key = f"decoder.up_blocks.{up_block_id}.resnets.{resnet_id}.conv1.weight"
+ elif ".residual.3.gamma" in key:
+ new_key = f"decoder.up_blocks.{up_block_id}.resnets.{resnet_id}.norm2.gamma"
+ elif ".residual.6.bias" in key:
+ new_key = f"decoder.up_blocks.{up_block_id}.resnets.{resnet_id}.conv2.bias"
+ elif ".residual.6.weight" in key:
+ new_key = f"decoder.up_blocks.{up_block_id}.resnets.{resnet_id}.conv2.weight"
+ else:
+ new_key = key
+ out[new_key] = value
+ continue
+
+ # 4b) Shortcut convs
+ if ".shortcut." in key:
+ if block_idx == 4:
+ # special-case first shortcut in block 1 -> resnets.0.conv_shortcut
+ new_key = key.replace(".shortcut.", ".resnets.0.conv_shortcut.")
+ new_key = new_key.replace("decoder.upsamples.4", "decoder.up_blocks.1")
+ else:
+ new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.")
+ new_key = new_key.replace(".shortcut.", ".conv_shortcut.")
+ out[new_key] = value
+ continue
+
+ # 4c) Upsamplers & time conv placement (the 3,7,11 pattern)
+ if (".resample." in key) or (".time_conv." in key):
+ if block_idx == 3:
+ new_key = key.replace("decoder.upsamples.3", "decoder.up_blocks.0.upsamplers.0")
+ elif block_idx == 7:
+ new_key = key.replace("decoder.upsamples.7", "decoder.up_blocks.1.upsamplers.0")
+ elif block_idx == 11:
+ new_key = key.replace("decoder.upsamples.11", "decoder.up_blocks.2.upsamplers.0")
+ else:
+ new_key = key.replace("decoder.upsamples.", "decoder.up_blocks.")
+ out[new_key] = value
+ continue
+
+ # default: just change the container name
+ out[key.replace("decoder.upsamples.", "decoder.up_blocks.")] = value
+ continue
+
+ # 5) Fallback: preserve anything not covered above
+ out[key] = value
+
+ return out
diff --git a/models/qwen/pipeline_qwenimage.py b/models/qwen/pipeline_qwenimage.py
index d70f094..e33fc86 100644
--- a/models/qwen/pipeline_qwenimage.py
+++ b/models/qwen/pipeline_qwenimage.py
@@ -177,8 +177,8 @@ class QwenImagePipeline(): #DiffusionPipeline
self.transformer=transformer
self.processor = processor
- self.latent_channels = self.vae.config.z_dim if getattr(self, "vae", None) else 16
- self.vae_scale_factor = 2 ** len(self.vae.temperal_downsample) if getattr(self, "vae", None) else 8
+ self.latent_channels = self.vae.z_dim if getattr(self, "vae", None) else 16
+ self.vae_scale_factor = 8 # 2 ** len(self.vae.temperal_downsample) if getattr(self, "vae", None) else 8
# QwenImage latents are turned into 2x2 patches and packed. This means the latent width and height has to be divisible
# by the patch size. So the vae scale factor is multiplied by the patch size to account for this
self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor * 2)
@@ -473,6 +473,7 @@ class QwenImagePipeline(): #DiffusionPipeline
device,
generator,
latents=None,
+ tile_size=0,
):
# VAE applies 8x compression on images but we must also account for packing which requires
# latent height and width to be divisible by 2.
@@ -489,7 +490,10 @@ class QwenImagePipeline(): #DiffusionPipeline
for image in images:
image = image.to(device=device, dtype=dtype)
if image.shape[1] != self.latent_channels:
- image_latents = self._encode_vae_image(image=image, generator=generator)
+ if self.use_Wan_VAE:
+ image_latents = self.vae.encode(image, tile_size = tile_size)[0].unsqueeze(0)
+ else:
+ image_latents = self._encode_vae_image(image=image, generator=generator)
else:
image_latents = image
if batch_size > image_latents.shape[0] and batch_size % image_latents.shape[0] == 0:
@@ -569,6 +573,7 @@ class QwenImagePipeline(): #DiffusionPipeline
lora_inpaint = False,
outpainting_dims = None,
qwen_edit_plus = False,
+ VAE_tile_size = 0,
):
r"""
Function invoked when calling the pipeline for generation.
@@ -642,7 +647,7 @@ class QwenImagePipeline(): #DiffusionPipeline
if callback != None:
callback(-1, None, True)
-
+ vae_z_dim = self.vae.z_dim
height = height or self.default_sample_size * self.vae_scale_factor
width = width or self.default_sample_size * self.vae_scale_factor
@@ -759,6 +764,7 @@ class QwenImagePipeline(): #DiffusionPipeline
device,
generator,
latents,
+ tile_size=VAE_tile_size
)
original_image_latents = None if image_latents is None else image_latents.clone()
@@ -944,17 +950,21 @@ class QwenImagePipeline(): #DiffusionPipeline
else:
latents = self._unpack_latents(latents, height, width, self.vae_scale_factor)
latents = latents.to(self.vae.dtype)
- latents_mean = (
- torch.tensor(self.vae.config.latents_mean)
- .view(1, self.vae.config.z_dim, 1, 1, 1)
- .to(latents.device, latents.dtype)
- )
- latents_std = 1.0 / torch.tensor(self.vae.config.latents_std).view(1, self.vae.config.z_dim, 1, 1, 1).to(
- latents.device, latents.dtype
- )
- latents = latents / latents_std + latents_mean
- output_image = self.vae.decode(latents, return_dict=False)[0][:, :, 0]
- if image_mask is not None and not lora_inpaint : #not (lora_inpaint and outpainting_dims is not None):
+ if self.use_Wan_VAE:
+ output_image = torch.cat([image.transpose(0,1) for image in self.vae.decode(latents, tile_size= VAE_tile_size)])
+ else:
+ latents_mean = (
+ torch.tensor(self.vae.config.latents_mean)
+ .view(1, vae_z_dim, 1, 1, 1)
+ .to(latents.device, latents.dtype)
+ )
+ latents_std = 1.0 / torch.tensor(self.vae.config.latents_std).view(1, vae_z_dim, 1, 1, 1).to(
+ latents.device, latents.dtype
+ )
+ latents = latents / latents_std + latents_mean
+ output_image = self.vae.decode(latents, return_dict=False)[0][:, :, 0]
+
+ if image_mask is not None and not lora_inpaint and self.vae.upsampling_set is None: #not (lora_inpaint and outpainting_dims is not None):
output_image = vae_images[0].squeeze(2) * (1 - image_mask_rebuilt) + output_image.to(vae_images[0] ) * image_mask_rebuilt
diff --git a/models/qwen/qwen_handler.py b/models/qwen/qwen_handler.py
index 66e5392..597de8b 100644
--- a/models/qwen/qwen_handler.py
+++ b/models/qwen/qwen_handler.py
@@ -22,6 +22,8 @@ class family_handler():
"profiles_dir": ["qwen"],
}
+ extra_model_def["vae_upsampler"] = [1,2]
+
if base_model_type in ["qwen_image_edit_20B", "qwen_image_edit_plus_20B"]:
extra_model_def["inpaint_support"] = True
extra_model_def["image_ref_choices"] = {
@@ -74,14 +76,21 @@ class family_handler():
@staticmethod
def query_model_files(computeList, base_model_type, model_filename, text_encoder_quantization):
text_encoder_filename = get_qwen_text_encoder_filename(text_encoder_quantization)
- return {
+ download_def = [{
"repoId" : "DeepBeepMeep/Qwen_image",
"sourceFolderList" : ["", "Qwen2.5-VL-7B-Instruct"],
"fileList" : [ ["qwen_vae.safetensors", "qwen_vae_config.json"], ["merges.txt", "tokenizer_config.json", "config.json", "vocab.json", "video_preprocessor_config.json", "preprocessor_config.json"] + computeList(text_encoder_filename) ]
- }
+ }]
+
+ download_def += [{
+ "repoId" : "DeepBeepMeep/Wan2.1",
+ "sourceFolderList" : ["" ],
+ "fileList" : [ ["Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors"] ]
+ }]
+ return download_def
@staticmethod
- def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, override_text_encoder = None):
+ def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, override_text_encoder = None, VAE_upsampling = None, **kwargs):
from .qwen_main import model_factory
from mmgp import offload
@@ -96,10 +105,12 @@ class family_handler():
dtype = dtype,
VAE_dtype = VAE_dtype,
mixed_precision_transformer = mixed_precision_transformer,
- save_quantized = save_quantized
+ save_quantized = save_quantized,
+ VAE_upsampling = VAE_upsampling,
)
- pipe = {"tokenizer" : pipe_processor.tokenizer, "transformer" : pipe_processor.transformer, "text_encoder" : pipe_processor.text_encoder, "vae" : pipe_processor.vae}
+ from ..wan.modules.vae import WanVAE
+ pipe = {"tokenizer" : pipe_processor.tokenizer, "transformer" : pipe_processor.transformer, "text_encoder" : pipe_processor.text_encoder, "vae" : pipe_processor.vae.model if isinstance(pipe_processor.vae, WanVAE) else pipe_processor.vae }
return pipe_processor, pipe
diff --git a/models/qwen/qwen_main.py b/models/qwen/qwen_main.py
index e5fcf85..c1c3333 100644
--- a/models/qwen/qwen_main.py
+++ b/models/qwen/qwen_main.py
@@ -46,6 +46,7 @@ class model_factory():
dtype = torch.bfloat16,
VAE_dtype = torch.float32,
mixed_precision_transformer = False,
+ VAE_upsampling = None,
):
@@ -87,10 +88,25 @@ class model_factory():
# text_encoder = offload.fast_load_transformers_model(text_encoder_filename, do_quantize=True, writable_tensors= True , modelClass=Qwen2_5_VLForConditionalGeneration, defaultConfigPath="text_encoder_config.json", verboseLevel=2)
# text_encoder.to(torch.float16)
# offload.save_model(text_encoder, "text_encoder_quanto_fp16.safetensors", do_quantize= True)
-
- vae = offload.fast_load_transformers_model( fl.locate_file("qwen_vae.safetensors"), writable_tensors= True , modelClass=AutoencoderKLQwenImage, defaultConfigPath= fl.locate_file("qwen_vae_config.json"))
-
+ use_Wan_VAE = True
+ VAE_upsampler_factor = 2 if VAE_upsampling is not None else 1
+
+ if use_Wan_VAE:
+ vae_checkpoint = "Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors" if VAE_upsampler_factor == 2 else "Wan2.1_VAE.safetensors"
+ from ..wan.modules.vae import WanVAE
+ vae = WanVAE( vae_pth=fl.locate_file(vae_checkpoint), dtype= VAE_dtype, upsampler_factor = VAE_upsampler_factor, device="cpu")
+ vae.device = "cuda" #self.device # need to set to cuda so that vae buffers are properly moved (although the rest will stay in the CPU)
+ else:
+ if VAE_upsampler_factor ==2 :
+ from .convert_diffusers_qwen_vae import convert_state_dict
+ vae_checkpoint = "Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors"
+ else:
+ convert_state_dict = None
+ vae_checkpoint = "qwen_vae.safetensors"
+ vae = offload.fast_load_transformers_model( fl.locate_file(vae_checkpoint), writable_tensors= True , modelClass=AutoencoderKLQwenImage, defaultConfigPath= fl.locate_file("qwen_vae_config.json"), configKwargs={"upsampler_factor": VAE_upsampler_factor}, preprocess_sd=convert_state_dict)
+ vae.upsampling_set = VAE_upsampling
self.pipeline = QwenImagePipeline(vae, text_encoder, tokenizer, transformer, processor)
+ self.pipeline.use_Wan_VAE = use_Wan_VAE
self.vae=vae
self.text_encoder=text_encoder
self.tokenizer=tokenizer
@@ -170,12 +186,17 @@ class model_factory():
self.scheduler=FlowMatchEulerDiscreteScheduler(**scheduler_config)
self.pipeline.scheduler = self.scheduler
if VAE_tile_size is not None:
+ if isinstance(VAE_tile_size, int):
+ tiling_type = VAE_tile_size
+ VAE_tile_size = [False, 0] if tiling_type == 0 else [True, 256]
self.vae.use_tiling = VAE_tile_size[0]
self.vae.tile_latent_min_height = VAE_tile_size[1]
self.vae.tile_latent_min_width = VAE_tile_size[1]
-
+ tile_size = VAE_tile_size[1]
+ # tile_size = 256
qwen_edit_plus = self.base_model_type in ["qwen_image_edit_plus_20B"]
- self.vae.enable_slicing()
+ if hasattr(self.vae, "enable_slicing"):
+ self.vae.enable_slicing()
# width, height = aspect_ratios["16:9"]
if n_prompt is None or len(n_prompt) == 0:
@@ -216,6 +237,7 @@ class model_factory():
lora_inpaint = image_mask is not None and model_mode == 1,
outpainting_dims = outpainting_dims,
qwen_edit_plus = qwen_edit_plus,
+ VAE_tile_size = tile_size,
)
if image is None: return None
return image.transpose(0, 1)
diff --git a/models/wan/any2video.py b/models/wan/any2video.py
index 44ec2dd..8c82a7c 100644
--- a/models/wan/any2video.py
+++ b/models/wan/any2video.py
@@ -76,7 +76,8 @@ class WanAny2V:
save_quantized = False,
dtype = torch.bfloat16,
VAE_dtype = torch.float32,
- mixed_precision_transformer = False
+ mixed_precision_transformer = False,
+ VAE_upsampling = None,
):
self.device = torch.device(f"cuda")
self.config = config
@@ -103,7 +104,7 @@ class WanAny2V:
tokenizer_path=fl.locate_folder("xlm-roberta-large"))
ignore_unused_weights = model_def.get("ignore_unused_weights", False)
-
+ vae_upsampler_factor = 1
vae_checkpoint2 = None
if model_def.get("wan_5B_class", False):
self.vae_stride = (4, 16, 16)
@@ -111,15 +112,19 @@ class WanAny2V:
vae = Wan2_2_VAE
else:
vae = WanVAE
- self.vae_stride = config.vae_stride
- if model_def.get("alpha_class", False):
+ self.vae_stride = config.vae_stride
+ if VAE_upsampling is not None:
+ vae_upsampler_factor = 2
+ vae_checkpoint ="Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors"
+ elif model_def.get("alpha_class", False):
vae_checkpoint ="wan_alpha_2.1_vae_rgb_channel.safetensors"
vae_checkpoint2 ="wan_alpha_2.1_vae_alpha_channel.safetensors"
else:
vae_checkpoint = "Wan2.1_VAE.safetensors"
self.patch_size = config.patch_size
- self.vae = vae( vae_pth=fl.locate_file(vae_checkpoint), dtype= VAE_dtype, device="cpu")
+ self.vae = vae( vae_pth=fl.locate_file(vae_checkpoint), dtype= VAE_dtype, upsampler_factor = vae_upsampler_factor, device="cpu")
+ self.vae.upsampling_set = VAE_upsampling
self.vae.device = self.device # need to set to cuda so that vae buffers are properly moved (although the rest will stay in the CPU)
self.vae2 = None
if vae_checkpoint2 is not None:
diff --git a/models/wan/modules/vae.py b/models/wan/modules/vae.py
index 8290d94..c6e16a2 100644
--- a/models/wan/modules/vae.py
+++ b/models/wan/modules/vae.py
@@ -410,7 +410,9 @@ class Decoder3d(nn.Module):
num_res_blocks=2,
attn_scales=[],
temperal_upsample=[False, True, True],
- dropout=0.0):
+ dropout=0.0,
+ upsampler_factor = 1,
+ ):
super().__init__()
self.dim = dim
self.z_dim = z_dim
@@ -453,7 +455,7 @@ class Decoder3d(nn.Module):
# output blocks
self.head = nn.Sequential(
RMS_norm(out_dim, images=False), nn.SiLU(),
- CausalConv3d(out_dim, 3, 3, padding=1))
+ CausalConv3d(out_dim, 3 * int(upsampler_factor*upsampler_factor), 3, padding=1))
def forward(self, x, feat_cache=None, feat_idx=[0]):
## conv1
@@ -529,6 +531,7 @@ class WanVAE_(nn.Module):
num_res_blocks=2,
attn_scales=[],
temperal_downsample=[True, True, False],
+ upsampler_factor = 1,
dropout=0.0):
super().__init__()
self.dim = dim
@@ -538,6 +541,7 @@ class WanVAE_(nn.Module):
self.attn_scales = attn_scales
self.temperal_downsample = temperal_downsample
self.temperal_upsample = temperal_downsample[::-1]
+ self.upsampler_factor = upsampler_factor
# modules
self.encoder = Encoder3d(dim, z_dim * 2, dim_mult, num_res_blocks,
@@ -545,7 +549,7 @@ class WanVAE_(nn.Module):
self.conv1 = CausalConv3d(z_dim * 2, z_dim * 2, 1)
self.conv2 = CausalConv3d(z_dim, z_dim, 1)
self.decoder = Decoder3d(dim, z_dim, dim_mult, num_res_blocks,
- attn_scales, self.temperal_upsample, dropout)
+ attn_scales, self.temperal_upsample, dropout, upsampler_factor)
def forward(self, x):
mu, log_var = self.encode(x)
@@ -600,8 +604,7 @@ class WanVAE_(nn.Module):
# z: [b,c,t,h,w]
if scale != None:
if isinstance(scale[0], torch.Tensor):
- z = z / scale[1].view(1, self.z_dim, 1, 1, 1) + scale[0].view(
- 1, self.z_dim, 1, 1, 1)
+ z = z / scale[1].view(1, self.z_dim, 1, 1, 1) + scale[0].view(1, self.z_dim, 1, 1, 1)
else:
z = z / scale[1] + scale[0]
iter_ = z.shape[2]
@@ -626,6 +629,10 @@ class WanVAE_(nn.Module):
feat_idx=self._conv_idx))
self.clear_cache()
out = torch.cat(out_list, 2)
+
+ if self.upsampler_factor > 1:
+ out = F.pixel_shuffle(out.movedim(2, 1), upscale_factor=self.upsampler_factor).movedim(1, 2) # pixel shuffle needs [..., C, H, W] format
+
return out
def blend_v(self, a: torch.Tensor, b: torch.Tensor, blend_extent: int) -> torch.Tensor:
@@ -648,13 +655,13 @@ class WanVAE_(nn.Module):
# z: [b,c,t,h,w]
if isinstance(scale[0], torch.Tensor):
- z = z / scale[1].view(1, self.z_dim, 1, 1, 1) + scale[0].view(
- 1, self.z_dim, 1, 1, 1)
+ z = z / scale[1].view(1, self.z_dim, 1, 1, 1) + scale[0].view( 1, self.z_dim, 1, 1, 1)
else:
z = z / scale[1] + scale[0]
overlap_size = int(tile_latent_min_size * (1 - tile_overlap_factor)) #8 0.75
+ tile_sample_min_size *= self.upsampler_factor
blend_extent = int(tile_sample_min_size * tile_overlap_factor) #256 0.25
row_limit = tile_sample_min_size - blend_extent
@@ -783,9 +790,11 @@ class WanVAE:
z_dim=16,
vae_pth='cache/vae_step_411000.pth',
dtype=torch.float,
+ upsampler_factor = 1,
device="cuda"):
self.dtype = dtype
self.device = device
+ self.z_dim = z_dim
mean = [
-0.7571, -0.7089, -0.9113, 0.1075, -0.1745, 0.9653, -0.1517, 1.5508,
@@ -802,6 +811,7 @@ class WanVAE:
# init model
self.model = _video_vae(
pretrained_path=vae_pth,
+ upsampler_factor = upsampler_factor,
z_dim=z_dim,
).to(dtype).eval() #.requires_grad_(False).to(device)
self.model._model_dtype = dtype
diff --git a/models/wan/wan_handler.py b/models/wan/wan_handler.py
index 886e2ea..26043b7 100644
--- a/models/wan/wan_handler.py
+++ b/models/wan/wan_handler.py
@@ -158,6 +158,9 @@ class family_handler():
else:
profiles_dir = "wan"
+ if (test_class_t2v(base_model_type) or vace_class or not base_model_type in ["chrono_edit"]) and not base_model_type in ["alpha"]:
+ extra_model_def["vae_upsampler"] = [1,2]
+
extra_model_def["profiles_dir"] = [profiles_dir]
extra_model_def["group"] = group
@@ -476,21 +479,21 @@ class family_handler():
download_def = [{
"repoId" : "DeepBeepMeep/Wan2.1",
"sourceFolderList" : ["xlm-roberta-large", "umt5-xxl", "" ],
- "fileList" : [ [ "models_clip_open-clip-xlm-roberta-large-vit-huge-14-bf16.safetensors", "sentencepiece.bpe.model", "special_tokens_map.json", "tokenizer.json", "tokenizer_config.json"], ["special_tokens_map.json", "spiece.model", "tokenizer.json", "tokenizer_config.json"] + computeList(text_encoder_filename) , ["Wan2.1_VAE.safetensors", "fantasy_proj_model.safetensors" ] + computeList(model_filename) ]
+ "fileList" : [ [ "models_clip_open-clip-xlm-roberta-large-vit-huge-14-bf16.safetensors", "sentencepiece.bpe.model", "special_tokens_map.json", "tokenizer.json", "tokenizer_config.json"], ["special_tokens_map.json", "spiece.model", "tokenizer.json", "tokenizer_config.json"] + computeList(text_encoder_filename) , ["Wan2.1_VAE.safetensors", "fantasy_proj_model.safetensors", "Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors"] + computeList(model_filename) ]
}]
if test_wan_5B(base_model_type):
download_def += [ {
"repoId" : "DeepBeepMeep/Wan2.2",
"sourceFolderList" : [""],
- "fileList" : [ [ "Wan2.2_VAE.safetensors" ] ]
+ "fileList" : [ [ "Wan2.2_VAE.safetensors"] ]
}]
return download_def
@staticmethod
- def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized= False, submodel_no_list = None, override_text_encoder = None):
+ def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized= False, submodel_no_list = None, override_text_encoder = None, VAE_upsampling = None, **kwargs):
from .configs import WAN_CONFIGS
if test_class_i2v(base_model_type):
@@ -512,7 +515,8 @@ class family_handler():
dtype = dtype,
VAE_dtype = VAE_dtype,
mixed_precision_transformer = mixed_precision_transformer,
- save_quantized = save_quantized
+ save_quantized = save_quantized,
+ VAE_upsampling = VAE_upsampling,
)
pipe = {"transformer": wan_model.model, "text_encoder" : wan_model.text_encoder.model, "vae": wan_model.vae.model }
diff --git a/shared/utils/utils.py b/shared/utils/utils.py
index 4f47fbd..2614c25 100644
--- a/shared/utils/utils.py
+++ b/shared/utils/utils.py
@@ -220,10 +220,10 @@ def convert_image_to_video(image):
out.release()
return temp_video.name
-def resize_lanczos(img, h, w):
+def resize_lanczos(img, h, w, method = None):
img = (img + 1).float().mul_(127.5)
img = Image.fromarray(np.clip(img.movedim(0, -1).cpu().numpy(), 0, 255).astype(np.uint8))
- img = img.resize((w,h), resample=Image.Resampling.LANCZOS)
+ img = img.resize((w,h), resample=Image.Resampling.LANCZOS if method is None else method)
img = torch.from_numpy(np.array(img).astype(np.float32)).movedim(-1, 0)
img = img.div(127.5).sub_(1)
return img
diff --git a/wgp.py b/wgp.py
index d004e0a..a25dba5 100644
--- a/wgp.py
+++ b/wgp.py
@@ -78,7 +78,7 @@ global_queue_ref = []
AUTOSAVE_FILENAME = "queue.zip"
PROMPT_VARS_MAX = 10
target_mmgp_version = "3.6.7"
-WanGP_version = "9.37"
+WanGP_version = "9.4"
settings_version = 2.39
max_source_video_frames = 3000
prompt_enhancer_image_caption_model, prompt_enhancer_image_caption_processor, prompt_enhancer_llm_model, prompt_enhancer_llm_tokenizer = None, None, None, None
@@ -616,12 +616,19 @@ def process_prompt_and_add_tasks(state, current_gallery_tab, model_choice):
switch_threshold2 = inputs["switch_threshold2"]
multi_prompts_gen_type = inputs["multi_prompts_gen_type"]
video_guide_outpainting = inputs["video_guide_outpainting"]
+ spatial_upsampling = inputs["spatial_upsampling"]
+ medium = "Videos" if image_mode == 0 else "Images"
outpainting_dims = get_outpainting_dims(video_guide_outpainting)
if server_config.get("fit_canvas", 0) == 2 and outpainting_dims is not None and any_letters(video_prompt_type, "VKF"):
gr.Info("Output Resolution Cropping will be not used for this Generation as it is not compatible with Video Outpainting")
+ if "vae" in spatial_upsampling:
+ if image_mode not in model_def.get("vae_upsampler", []):
+ gr.Info(f"VAE Spatial Upsampling is not available for {medium}")
+ return ret()
+
if len(activated_loras) > 0:
error = check_loras_exist(model_type, activated_loras)
if len(error) > 0:
@@ -3208,7 +3215,7 @@ def setup_prompt_enhancer(pipe, kwargs):
-def load_models(model_type, override_profile = -1):
+def load_models(model_type, override_profile = -1, **model_kwargs):
global transformer_type, loaded_profile
base_model_type = get_base_model_type(model_type)
model_def = get_model_def(model_type)
@@ -3290,10 +3297,11 @@ def load_models(model_type, override_profile = -1):
print(f"Loading Text Encoder '{override_text_encoder}' ...")
else:
override_text_encoder = None
-
+ set_seed(42)
+ torch.set_default_device('cpu')
wan_model, pipe = model_types_handlers[base_model_type].load_model(
local_model_file_list, model_type, base_model_type, model_def, quantizeTransformer = quantizeTransformer, text_encoder_quantization = text_encoder_quantization,
- dtype = transformer_dtype, VAE_dtype = VAE_dtype, mixed_precision_transformer = mixed_precision_transformer, save_quantized = save_quantized, submodel_no_list = model_submodel_no_list, override_text_encoder = override_text_encoder )
+ dtype = transformer_dtype, VAE_dtype = VAE_dtype, mixed_precision_transformer = mixed_precision_transformer, save_quantized = save_quantized, submodel_no_list = model_submodel_no_list, override_text_encoder = override_text_encoder, **model_kwargs )
kwargs = {}
if "pipe" in pipe:
@@ -4435,7 +4443,13 @@ def perform_temporal_upsampling(sample, previous_last_frame, temporal_upsampling
def perform_spatial_upsampling(sample, spatial_upsampling):
from shared.utils.utils import resize_lanczos
- if spatial_upsampling == "lanczos1.5":
+ if spatial_upsampling == "vae2":
+ return sample
+ method = None
+ if spatial_upsampling == "vae1":
+ scale = 0.5
+ method = Image.Resampling.BICUBIC
+ elif spatial_upsampling == "lanczos1.5":
scale = 1.5
else:
scale = 2
@@ -4448,7 +4462,7 @@ def perform_spatial_upsampling(sample, spatial_upsampling):
w = int(w)
frames_to_upsample = [sample[:, i] for i in range( sample.shape[1]) ]
def upsample_frames(frame):
- return resize_lanczos(frame, h, w).unsqueeze(1)
+ return resize_lanczos(frame, h, w, method).unsqueeze(1)
sample = torch.cat(process_images_multithread(upsample_frames, frames_to_upsample, "upsample", wrap_in_list = False, max_workers=get_default_workers(), in_place=True), dim=1)
frames_to_upsample = None
return sample
@@ -4981,12 +4995,18 @@ def generate_video(
if "P" in preload_model_policy and not "U" in preload_model_policy:
while wan_model == None:
time.sleep(1)
-
+ vae_upsampling = model_def.get("vae_upsampler", None)
+ model_kwargs = {}
+ if vae_upsampling is not None:
+ new_vae_upsampling = None if image_mode not in vae_upsampling or "vae" not in spatial_upsampling else spatial_upsampling
+ old_vae_upsampling = None if reload_needed or wan_model is None or not hasattr(wan_model, "vae") else wan_model.vae.upsampling_set
+ reload_needed = reload_needed or old_vae_upsampling != new_vae_upsampling
+ if new_vae_upsampling: model_kwargs = {"VAE_upsampling": new_vae_upsampling}
if model_type != transformer_type or reload_needed or override_profile>0 and override_profile != loaded_profile or override_profile<0 and default_profile != loaded_profile:
wan_model = None
release_model()
send_cmd("status", f"Loading model {get_model_name(model_type)}...")
- wan_model, offloadobj = load_models(model_type, override_profile)
+ wan_model, offloadobj = load_models(model_type, override_profile, **model_kwargs)
send_cmd("status", "Model loaded")
reload_needed= False
overridden_attention = get_overridden_attention(model_type)
@@ -5768,7 +5788,7 @@ def generate_video(
output_new_audio_data = full_generated_audio
- if len(temporal_upsampling) > 0 or len(spatial_upsampling) > 0:
+ if len(temporal_upsampling) > 0 or len(spatial_upsampling) > 0 and not "vae2" in spatial_upsampling:
send_cmd("progress", [0, get_latest_status(state,"Upsampling")])
output_fps = fps
@@ -8264,7 +8284,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
video_source = gr.Video(label= "Video to Continue", height = gallery_height, visible= "V" in image_prompt_type_value, value= ui_defaults.get("video_source", None), elem_id="video_input")
image_end_row, image_end, image_end_extra = get_image_gallery(label= get_image_end_label(ui_defaults.get("multi_prompts_gen_type", 0)), value = ui_defaults.get("image_end", None), visible= any_letters(image_prompt_type_value, "SVL") and ("E" in image_prompt_type_value) )
if model_mode_choices is None or image_mode_value not in model_modes_visibility:
- model_mode = gr.Dropdown(value=None, visible=False)
+ model_mode = gr.Dropdown(value=None, label="model mode", visible=False, allow_custom_value= True)
else:
model_mode_value = get_default_value(model_mode_choices["choices"], ui_defaults.get("model_mode", None), model_mode_choices["default"] )
model_mode = gr.Dropdown(choices=model_mode_choices["choices"], value=model_mode_value, label=model_mode_choices["label"], visible=True)
@@ -8760,7 +8780,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
with gr.Column():
gr.Markdown("<B>Upsampling - postprocessing that may improve fluidity and the size of the video</B>")
- def gen_upsampling_dropdowns(temporal_upsampling, spatial_upsampling , film_grain_intensity, film_grain_saturation, element_class= None, max_height= None, image_outputs = False):
+ def gen_upsampling_dropdowns(temporal_upsampling, spatial_upsampling , film_grain_intensity, film_grain_saturation, element_class= None, max_height= None, image_outputs = False, any_vae_upsampling = False):
temporal_upsampling = gr.Dropdown(
choices=[
("Disabled", ""),
@@ -8774,12 +8794,13 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
elem_classes= element_class
# max_height = max_height
)
+
spatial_upsampling = gr.Dropdown(
choices=[
("Disabled", ""),
("Lanczos x1.5", "lanczos1.5"),
("Lanczos x2.0", "lanczos2"),
- ],
+ ] + ([("VAE x1.0 (refined)", "vae1"),("VAE x2.0", "vae2")] if any_vae_upsampling else []) ,
value=spatial_upsampling,
visible=True,
scale = 1,
@@ -8793,7 +8814,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
film_grain_saturation = gr.Slider(0.0, 1, value=film_grain_saturation, step=0.01, label="Film Grain Saturation")
return temporal_upsampling, spatial_upsampling, film_grain_intensity, film_grain_saturation
- temporal_upsampling, spatial_upsampling, film_grain_intensity, film_grain_saturation = gen_upsampling_dropdowns(ui_defaults.get("temporal_upsampling", ""), ui_defaults.get("spatial_upsampling", ""), ui_defaults.get("film_grain_intensity", 0), ui_defaults.get("film_grain_saturation", 0.5), image_outputs= image_outputs)
+ temporal_upsampling, spatial_upsampling, film_grain_intensity, film_grain_saturation = gen_upsampling_dropdowns(ui_defaults.get("temporal_upsampling", ""), ui_defaults.get("spatial_upsampling", ""), ui_defaults.get("film_grain_intensity", 0), ui_defaults.get("film_grain_saturation", 0.5), image_outputs= image_outputs, any_vae_upsampling= "vae_upsampler"in model_def)
with gr.Tab("Audio", visible = not (image_outputs or audio_only)) as audio_tab:
any_audio_source = not (image_outputs or audio_only)