From 617913f8891dc5cf9cd6ad852666bc99ae3fa884 Mon Sep 17 00:00:00 2001 From: Tung Nguyen Date: Mon, 25 Sep 2023 22:49:01 +0700 Subject: [PATCH] fix eject bugs --- animatediff/nodes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/animatediff/nodes.py b/animatediff/nodes.py index ea5645d..9b06dc9 100644 --- a/animatediff/nodes.py +++ b/animatediff/nodes.py @@ -54,8 +54,9 @@ class AnimateDiffModuleLoader: curr_layer.weight.data += alpha * state_dict[key].to(curr_layer.weight.data.device) def eject_loras(self, motion_module: MotionWrapper, lora_stack: List[Tuple[float, Dict[str, Tensor]]]): - for lora in lora_stack.reverse(): - (alpha, state_dict) = lora + lora_stack.reverse() # should not matter but just in case + for lora in lora_stack: + (state_dict, alpha) = lora for key in state_dict: layer_infos = key.split(".") @@ -76,7 +77,7 @@ class AnimateDiffModuleLoader: # inject loras if motion_module.is_v2: - if hasattr(motion_module, "lora_stack"): + if hasattr(motion_module, "lora_stack") and isinstance(motion_module.lora_stack, list): self.eject_loras(motion_module, motion_module.lora_stack) delattr(motion_module, "lora_stack")