From 94c186bb4c3960c952228d3fe8cf48e7b9673a11 Mon Sep 17 00:00:00 2001 From: Ryan Dick Date: Thu, 14 Sep 2023 15:45:25 -0400 Subject: [PATCH] Fix bug in IPAdapter.to(...). --- invokeai/backend/ip_adapter/ip_adapter.py | 4 +++- invokeai/backend/model_management/models/ip_adapter.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/invokeai/backend/ip_adapter/ip_adapter.py b/invokeai/backend/ip_adapter/ip_adapter.py index 30866cc5af..31ee815eae 100644 --- a/invokeai/backend/ip_adapter/ip_adapter.py +++ b/invokeai/backend/ip_adapter/ip_adapter.py @@ -18,6 +18,8 @@ from diffusers.models import UNet2DConditionModel from PIL import Image from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection +from invokeai.backend.model_management.models.base import calc_model_size_by_data + from .attention_processor import AttnProcessor, IPAttnProcessor from .resampler import Resampler @@ -94,7 +96,7 @@ class IPAdapter: self._image_proj_model.to(device=self.device, dtype=self.dtype) if self._attn_processors is not None: - torch.nn.ModuleList(self._attn_processors).to(device=self.device, dtype=self.dtype) + torch.nn.ModuleList(self._attn_processors.values()).to(device=self.device, dtype=self.dtype) def _init_image_proj_model(self, state_dict): return ImageProjModel.from_state_dict(state_dict, self._num_tokens).to(self.device, dtype=self.dtype) diff --git a/invokeai/backend/model_management/models/ip_adapter.py b/invokeai/backend/model_management/models/ip_adapter.py index 59a9e4846b..976711c720 100644 --- a/invokeai/backend/model_management/models/ip_adapter.py +++ b/invokeai/backend/model_management/models/ip_adapter.py @@ -72,7 +72,6 @@ class IPAdapterModel(ModelBase): if child_type is not None: raise ValueError("There are no child models in an IP-Adapter model.") - # TODO(ryand): Update self.model_size when the model is loaded from disk. return self.model_size def get_model(