MCPcopy Index your code
hub / github.com/huggingface/diffusers / convert_ltx2_video_vae

Function convert_ltx2_video_vae

scripts/convert_ltx2_to_diffusers.py:628–653  ·  view source on GitHub ↗
(
    original_state_dict: dict[str, Any], version: str, timestep_conditioning: bool
)

Source from the content-addressed store, hash-verified

626
627
628def convert_ltx2_video_vae(
629 original_state_dict: dict[str, Any], version: str, timestep_conditioning: bool
630) -> dict[str, Any]:
631 config, rename_dict, special_keys_remap = get_ltx2_video_vae_config(version, timestep_conditioning)
632 diffusers_config = config["diffusers_config"]
633
634 with init_empty_weights():
635 vae = AutoencoderKLLTX2Video.from_config(diffusers_config)
636
637 # Handle official code --> diffusers key remapping via the remap dict
638 for key in list(original_state_dict.keys()):
639 new_key = key[:]
640 for replace_key, rename_key in rename_dict.items():
641 new_key = new_key.replace(replace_key, rename_key)
642 update_state_dict_inplace(original_state_dict, key, new_key)
643
644 # Handle any special logic which can't be expressed by a simple 1:1 remapping with the handlers in
645 # special_keys_remap
646 for key in list(original_state_dict.keys()):
647 for special_key, handler_fn_inplace in special_keys_remap.items():
648 if special_key not in key:
649 continue
650 handler_fn_inplace(key, original_state_dict)
651
652 vae.load_state_dict(original_state_dict, strict=True, assign=True)
653 return vae
654
655
656def get_ltx2_audio_vae_config(version: str) -> tuple[dict[str, Any], dict[str, Any], dict[str, Any]]:

Callers 1

mainFunction · 0.85

Calls 4

from_configMethod · 0.45
load_state_dictMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…