| 468 | |
| 469 | @comfy_node(name="LTXICLoRALoaderModelOnly") |
| 470 | class LTXICLoRALoaderModelOnly(io.ComfyNode): |
| 471 | @classmethod |
| 472 | def define_schema(cls): |
| 473 | return io.Schema( |
| 474 | node_id="LTXICLoRALoaderModelOnly", |
| 475 | display_name=NODES_DISPLAY_NAME_PREFIX + " IC-LoRA Loader Model Only", |
| 476 | category="Lightricks/IC-LoRA", |
| 477 | description="Loads a LoRA model and extracts the latent_downscale_factor from the safetensors metadata.", |
| 478 | inputs=[ |
| 479 | io.Model.Input("model"), |
| 480 | io.Combo.Input( |
| 481 | "lora_name", |
| 482 | options=folder_paths.get_filename_list("loras"), |
| 483 | ), |
| 484 | io.Float.Input( |
| 485 | "strength_model", |
| 486 | default=1.0, |
| 487 | min=-100.0, |
| 488 | max=100.0, |
| 489 | step=0.01, |
| 490 | ), |
| 491 | ], |
| 492 | outputs=[ |
| 493 | io.Model.Output("model"), |
| 494 | io.Float.Output("latent_downscale_factor"), |
| 495 | ], |
| 496 | ) |
| 497 | |
| 498 | @classmethod |
| 499 | def execute(cls, model, lora_name, strength_model) -> io.NodeOutput: |
| 500 | lora_path = folder_paths.get_full_path_or_raise("loras", lora_name) |
| 501 | |
| 502 | # Load lora and extract metadata |
| 503 | lora, metadata = comfy.utils.load_torch_file( |
| 504 | lora_path, safe_load=True, return_metadata=True |
| 505 | ) |
| 506 | |
| 507 | # Extract latent_downscale_factor from metadata |
| 508 | try: |
| 509 | latent_downscale_factor = float(metadata["reference_downscale_factor"]) |
| 510 | except (KeyError, ValueError, TypeError): |
| 511 | latent_downscale_factor = 1.0 |
| 512 | logging.warning( |
| 513 | "Failed to extract reference_downscale_factor from metadata for %s, using 1.0", |
| 514 | lora_path, |
| 515 | ) |
| 516 | |
| 517 | if strength_model == 0: |
| 518 | return io.NodeOutput(model, latent_downscale_factor) |
| 519 | |
| 520 | model_lora, _ = comfy.sd.load_lora_for_models( |
| 521 | model, None, lora, strength_model, 0 |
| 522 | ) |
| 523 | return io.NodeOutput(model_lora, latent_downscale_factor) |
| 524 | |
| 525 | |
| 526 | def _patchify_audio_latent(latent): |
nothing calls this directly
no outgoing calls
no test coverage detected