feat: make VAE optional for Qwen-Image, use bundled VAE by default

Qwen-Image models come with their own bundled AutoencoderKLQwenImage VAE
in the /vae subdirectory. This change:

- Makes the VAE field optional in QwenImageModelLoaderInvocation
- Uses the bundled VAE from the main model when no VAE is specified
- Allows overriding with a custom VAE if desired

This solves the issue where users couldn't find a Qwen-specific VAE to select,
since the VAE is bundled with the main model rather than being a separate download.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
psychedelicious
2025-09-09 19:06:51 +10:00
parent 5c55805879
commit bfc1729f63
2 changed files with 16 additions and 5 deletions

View File

@@ -47,22 +47,33 @@ class QwenImageModelLoaderInvocation(BaseInvocation):
# ui_model_type=ModelType.VL
)
vae_model: ModelIdentifierField = InputField(
vae_model: ModelIdentifierField | None = InputField(
description="VAE model for Qwen-Image",
title="VAE",
ui_model_base=BaseModelType.QwenImage,
ui_model_type=ModelType.VAE,
default=None,
)
def invoke(self, context: InvocationContext) -> QwenImageModelLoaderOutput:
# Validate that all models exist
for key in [self.model.key, self.qwen2_5_vl_model.key, self.vae_model.key]:
# Validate that required models exist
for key in [self.model.key, self.qwen2_5_vl_model.key]:
if not context.models.exists(key):
raise ValueError(f"Unknown model: {key}")
# Validate optional VAE model if provided
if self.vae_model and not context.models.exists(self.vae_model.key):
raise ValueError(f"Unknown model: {self.vae_model.key}")
# Create submodel references
transformer = self.model.model_copy(update={"submodel_type": SubModelType.Transformer})
vae = self.vae_model.model_copy(update={"submodel_type": SubModelType.VAE})
# Use provided VAE or extract from main model
if self.vae_model:
vae = self.vae_model.model_copy(update={"submodel_type": SubModelType.VAE})
else:
# Use the VAE bundled with the Qwen-Image model
vae = self.model.model_copy(update={"submodel_type": SubModelType.VAE})
# For Qwen-Image, we use Qwen2.5-VL as the text encoder
tokenizer = self.qwen2_5_vl_model.model_copy(update={"submodel_type": SubModelType.Tokenizer})

View File

@@ -18344,7 +18344,7 @@ export type components = {
qwen2_5_vl_model: components["schemas"]["ModelIdentifierField"];
/**
* VAE
* @description VAE model for Qwen-Image
* @description VAE model (uses Qwen-Image's bundled VAE if not specified)
* @default null
*/
vae_model?: components["schemas"]["ModelIdentifierField"] | null;