Files
automatic/pipelines/generic_shared.py
T
CalamitousFelicitousness 48fad8524e feat(krea2): add Krea 2 (K2) image model support
Krea 2 is a 12.9B single-stream flow-matching DiT trained from scratch, using a Qwen3-VL-4B text encoder and the Qwen-Image VAE. The transformer is vendored as a diffusers ModelMixin whose module tree mirrors the checkpoint, so weights load with no key conversion; the pipeline ports the reference encode, flow-matching denoise, and VAE decode. The text encoder is shared at runtime via the existing dedup registry, so Base and Turbo reuse one Qwen3-VL-4B copy.

Covers text-to-image, image-to-image, native LoRA, and the single-file UNET override. Also completes SD.Next's partial Qwen-Image VAE support (5D decode input and TAESD preview mapping) that K2 shares.
2026-06-23 04:41:54 +01:00

117 lines
4.3 KiB
Python

import os
import transformers
# order is first-found, so list more specific models first and more general models later
# e.g. 9b before 4b and sdnq before base
shared_te_map = {
'T5-XXL SDNQ-UInt4': {
'cls': transformers.T5EncoderModel,
'identifier': 'sdnq-uint4',
'target_repo': 'Disty0/FLUX.1-dev-SDNQ-uint4-svd-r32',
},
'T5-XXL Base': { # template
'cls': transformers.T5EncoderModel, # desired model class, used as primary matching criteria
'identifier': None, # additional identifier to match in repo_id or None to ignore
'target_repo': 'Disty0/t5-xxl', # repo to load from instead of original repo_id
'target_subfolder': None, # subfolder in repo to load from, None to ignore
'config_class': transformers.T5Config, # config class to use for loading or None to ignore
'config_path': os.path.join('configs', 'flux', 'text_encoder_2', 'config.json'), # path to config file to use for loading or None to ignore
},
'UMT5 SDNQ-UInt4': {
'cls': transformers.UMT5EncoderModel,
'identifier': 'sdnq-uint4',
'target_repo': 'Disty0/Wan2.2-T2V-A14B-SDNQ-uint4-svd-r32',
'target_subfolder': 'text_encoder',
},
'UMT5 Base': {
'cls': transformers.UMT5EncoderModel,
'target_repo': 'Wan-AI/Wan2.1-T2V-1.3B-Diffusers',
'target_subfolder': 'text_encoder',
},
'Qwen-2.5 SDNQ-4Bit': {
'cls': transformers.Qwen2_5_VLForConditionalGeneration,
'identifier': 'sdnq-4bit',
'target_repo': 'Disty0/Qwen-Image-2512-SDNQ-uint4-svd-r32',
'target_subfolder': 'text_encoder',
},
'Qwen-2.5 SDNQ-UInt4': {
'cls': transformers.Qwen2_5_VLForConditionalGeneration,
'identifier': 'sdnq-uint4',
'target_repo': 'Disty0/Qwen-Image-2512-SDNQ-uint4-svd-r32',
'target_subfolder': 'text_encoder',
},
'Qwen-2.5 Base': {
'cls': transformers.Qwen2_5_VLForConditionalGeneration,
'target_repo': 'hunyuanvideo-community/HunyuanImage-2.1-Diffusers',
'target_subfolder': 'text_encoder',
},
'Qwen-3 9B SDNQ-4bit': {
'cls': transformers.Qwen3ForCausalLM,
'identifier': '9b-sdnq-4bit',
'target_repo': 'Disty0/FLUX.2-klein-9B-SDNQ-4bit-dynamic-svd-r32',
'target_subfolder': 'text_encoder',
},
'Qwen-3 9B SDNQ-UInt4': {
'cls': transformers.Qwen3ForCausalLM,
'identifier': '9b-sdnq-uint4',
'target_repo': 'Disty0/FLUX.2-klein-9B-SDNQ-4bit-dynamic-svd-r32',
'target_subfolder': 'text_encoder',
},
'Qwen-3 9B Base': {
'cls': transformers.Qwen3ForCausalLM,
'identifier': '9b',
'target_repo': 'black-forest-labs/FLUX.2-klein-9B',
'target_subfolder': 'text_encoder',
},
'Qwen-3 4B SDNQ-4Bit': { # match after 9b
'cls': transformers.Qwen3ForCausalLM,
'identifier': 'sdnq-4bit',
'target_repo': 'Disty0/Z-Image-Turbo-SDNQ-uint4-svd-r32',
'target_subfolder': 'text_encoder',
},
'Qwen-3 4B SDNQ-UInt4': {
'cls': transformers.Qwen3ForCausalLM,
'identifier': 'sdnq-uint4',
'target_repo': 'Disty0/Z-Image-Turbo-SDNQ-uint4-svd-r32',
'target_subfolder': 'text_encoder',
},
'Qwen-3 4B Base': {
'cls': transformers.Qwen3ForCausalLM,
'target_repo': 'Tongyi-MAI/Z-Image-Turbo',
'target_subfolder': 'text_encoder',
},
'Qwen-3 0.5B SDNQ-UInt4': {
'cls': transformers.Qwen3Model,
'identifier': 'uint4',
'target_repo': 'vladmandic/Anima-1.0-Base-sdnq-svd-dynamic-uint4',
'target_subfolder': 'text_encoder',
},
'Qwen-3 0.5B Base': {
'cls': transformers.Qwen3Model,
'target_repo': 'vladmandic/Anima-1.0-Base',
'target_subfolder': 'text_encoder',
},
'Qwen3-VL 4B Base': { # Krea 2 base+turbo share one canonical 4B copy
'cls': transformers.Qwen3VLModel,
'identifier': 'krea',
'target_repo': 'Qwen/Qwen3-VL-4B-Instruct',
},
'Qwen3-VL 8B SDNQ-UInt4': {
'cls': transformers.Qwen3VLModel,
'identifier': 'uint4',
'target_repo': 'Disty0/Ideogram-4-SDNQ-4bit-dynamic-hadamard',
'target_subfolder': 'text_encoder',
},
'Qwen3-VL 8B Base': {
'cls': transformers.Qwen3VLModel,
'target_repo': 'Qwen/Qwen3-VL-8B-Instruct',
},
}