From 6e4c2d3685c9aa765c88228baae8607994452cde Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Fri, 29 Mar 2024 12:34:56 +0530 Subject: [PATCH] fix: Fail when unexpected keys are found in IP Adapter models --- invokeai/backend/ip_adapter/ip_adapter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/invokeai/backend/ip_adapter/ip_adapter.py b/invokeai/backend/ip_adapter/ip_adapter.py index 1155e571ae..02788c0ba6 100644 --- a/invokeai/backend/ip_adapter/ip_adapter.py +++ b/invokeai/backend/ip_adapter/ip_adapter.py @@ -214,6 +214,8 @@ def load_ip_adapter_tensors(ip_adapter_ckpt_path: str, device: str) -> IPAdapter state_dict["image_proj"][key.replace("image_proj.", "")] = model.get_tensor(key) elif key.startswith("ip_adapter."): state_dict["ip_adapter"][key.replace("ip_adapter.", "")] = model.get_tensor(key) + else: + raise RuntimeError(f"Encountered unexpected IP Adapter state dict key: '{key}'.") else: ip_adapter_diffusers_checkpoint_path = ip_adapter_ckpt_path + "/ip_adapter.bin" state_dict = torch.load(ip_adapter_diffusers_checkpoint_path, map_location="cpu")