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

Function convert_ltx2_audio_vae

scripts/convert_ltx2_to_diffusers.py:710–733  ·  view source on GitHub ↗
(original_state_dict: dict[str, Any], version: str)

Source from the content-addressed store, hash-verified

708
709
710def convert_ltx2_audio_vae(original_state_dict: dict[str, Any], version: str) -> dict[str, Any]:
711 config, rename_dict, special_keys_remap = get_ltx2_audio_vae_config(version)
712 diffusers_config = config["diffusers_config"]
713
714 with init_empty_weights():
715 vae = AutoencoderKLLTX2Audio.from_config(diffusers_config)
716
717 # Handle official code --> diffusers key remapping via the remap dict
718 for key in list(original_state_dict.keys()):
719 new_key = key[:]
720 for replace_key, rename_key in rename_dict.items():
721 new_key = new_key.replace(replace_key, rename_key)
722 update_state_dict_inplace(original_state_dict, key, new_key)
723
724 # Handle any special logic which can't be expressed by a simple 1:1 remapping with the handlers in
725 # special_keys_remap
726 for key in list(original_state_dict.keys()):
727 for special_key, handler_fn_inplace in special_keys_remap.items():
728 if special_key not in key:
729 continue
730 handler_fn_inplace(key, original_state_dict)
731
732 vae.load_state_dict(original_state_dict, strict=True, assign=True)
733 return vae
734
735
736def get_ltx2_vocoder_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…