(original_state_dict: dict[str, Any], version: str)
| 480 | |
| 481 | |
| 482 | def convert_ltx2_connectors(original_state_dict: dict[str, Any], version: str) -> LTX2TextConnectors: |
| 483 | config, rename_dict, special_keys_remap = get_ltx2_connectors_config(version) |
| 484 | diffusers_config = config["diffusers_config"] |
| 485 | |
| 486 | _, connector_state_dict = split_transformer_and_connector_state_dict(original_state_dict) |
| 487 | if len(connector_state_dict) == 0: |
| 488 | raise ValueError("No connector weights found in the provided state dict.") |
| 489 | |
| 490 | with init_empty_weights(): |
| 491 | connectors = LTX2TextConnectors.from_config(diffusers_config) |
| 492 | |
| 493 | for key in list(connector_state_dict.keys()): |
| 494 | new_key = key[:] |
| 495 | for replace_key, rename_key in rename_dict.items(): |
| 496 | new_key = new_key.replace(replace_key, rename_key) |
| 497 | update_state_dict_inplace(connector_state_dict, key, new_key) |
| 498 | |
| 499 | for key in list(connector_state_dict.keys()): |
| 500 | for special_key, handler_fn_inplace in special_keys_remap.items(): |
| 501 | if special_key not in key: |
| 502 | continue |
| 503 | handler_fn_inplace(key, connector_state_dict) |
| 504 | |
| 505 | connectors.load_state_dict(connector_state_dict, strict=True, assign=True) |
| 506 | return connectors |
| 507 | |
| 508 | |
| 509 | def get_ltx2_video_vae_config( |
no test coverage detected
searching dependent graphs…