Download comfyui-moonpack/dynamic_lora_stack_node.py from MarkLilly/mis-custom-nodes: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/MarkLilly/mis-custom-nodes/resolve/main/comfyui-moonpack/dynamic_lora_stack_node.py
- Command line
-
hf download hf://MarkLilly/mis-custom-nodes/comfyui-moonpack/dynamic_lora_stack_node.py
-
curl -L -o dynamic_lora_stack_node.py https://huggingface.co/MarkLilly/mis-custom-nodes/resolve/main/comfyui-moonpack/dynamic_lora_stack_node.py
1.22 kB
| from .utils import FlexibleOptionalInputType | |
| class DynamicLoraStack: | |
| def INPUT_TYPES(s): | |
| return { | |
| "required": {}, | |
| "optional": FlexibleOptionalInputType("WANVIDLORA") | |
| } | |
| RETURN_TYPES = ("WANVIDLORA",) | |
| FUNCTION = "stack_loras" | |
| CATEGORY = "moonpack/lora" | |
| def stack_loras(self, **kwargs): | |
| loras = [] | |
| # Sort kwargs by key to maintain the order of inputs | |
| sorted_items = sorted(kwargs.items(), key=lambda item: int(item[0].split('_')[1])) | |
| for key, value in sorted_items: | |
| if key.startswith("lora_") and value is not None: | |
| loras.append(value) | |
| if not loras: | |
| return (None,) | |
| # Flatten the list of loras, as some inputs might be stacks themselves | |
| stacked_loras = [] | |
| for lora in loras: | |
| if isinstance(lora, list): | |
| stacked_loras.extend(lora) | |
| else: | |
| stacked_loras.append(lora) | |
| return (stacked_loras,) | |
| NODE_CLASS_MAPPINGS = { | |
| "DynamicLoraStack": DynamicLoraStack | |
| } | |
| NODE_DISPLAY_NAME_MAPPINGS = { | |
| "DynamicLoraStack": "Dynamic LoRA Stack" | |
| } | |