{"record":{"id":"baf505a9fbf1f53b","repo":"invoke-ai/InvokeAI","slug":"self-class-has-the-config-param-encoder-hid-baf505","errorCode":null,"errorMessage":"{self.__class__} has the config param `encoder_hid_dim_type` set to 'image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`","messagePattern":"(.+?) has the config param `encoder_hid_dim_type` set to 'image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/hidiffusion/hidiffusion.py","lineNumber":1147,"sourceCode":"                # Kadinsky 2.1 - style\n                if \"image_embeds\" not in added_cond_kwargs:\n                    raise ValueError(\n                        f\"{self.__class__} has the config param `encoder_hid_dim_type` set to 'text_image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`\"\n                    )\n\n                image_embeds = added_cond_kwargs.get(\"image_embeds\")\n                encoder_hidden_states = self.encoder_hid_proj(encoder_hidden_states, image_embeds)\n            elif self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == \"image_proj\":\n                # Kandinsky 2.2 - style\n                if \"image_embeds\" not in added_cond_kwargs:\n                    raise ValueError(\n                        f\"{self.__class__} has the config param `encoder_hid_dim_type` set to 'image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`\"\n                    )\n                image_embeds = added_cond_kwargs.get(\"image_embeds\")\n                encoder_hidden_states = self.encoder_hid_proj(image_embeds)\n            elif self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == \"ip_image_proj\":\n                if \"image_embeds\" not in added_cond_kwargs:\n                    raise ValueError(\n                        f\"{self.__class__} has the config param `encoder_hid_dim_type` set to 'ip_image_proj' which requires the keyword argument `image_embeds` to be passed in  `added_conditions`\"\n                    )\n                image_embeds = added_cond_kwargs.get(\"image_embeds\")\n                image_embeds = self.encoder_hid_proj(image_embeds).to(encoder_hidden_states.dtype)\n                encoder_hidden_states = torch.cat([encoder_hidden_states, image_embeds], dim=1)\n\n            # 2. pre-process\n            sample = self.conv_in(sample)\n\n            # 2.5 GLIGEN position net\n            if cross_attention_kwargs is not None and cross_attention_kwargs.get(\"gligen\", None) is not None:\n                cross_attention_kwargs = cross_attention_kwargs.copy()\n                gligen_args = cross_attention_kwargs.pop(\"gligen\")\n                cross_attention_kwargs[\"gligen\"] = {\"objs\": self.position_net(**gligen_args)}\n\n            # 3. down\n            lora_scale = cross_attention_kwargs.get(\"scale\", 1.0) if cross_attention_kwargs is not None else 1.0\n            if USE_PEFT_BACKEND:","sourceCodeStart":1129,"sourceCodeEnd":1165,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/hidiffusion/hidiffusion.py#L1129-L1165","documentation":"For `encoder_hid_dim_type='ip_image_proj'` (IP-Adapter style), the projection embeds `added_cond_kwargs['image_embeds']` and concatenates the result to `encoder_hidden_states` along the token dimension. Without `image_embeds` there is nothing to project, so forward raises.","triggerScenarios":"Calling forward on a UNet with IP-Adapter encoder projection (`encoder_hid_dim_type='ip_image_proj'`) without `added_cond_kwargs={'image_embeds': ...}`, typically after loading an IP-Adapter into the UNet.","commonSituations":"Loading an IP-Adapter via `load_ip_adapter` but calling `unet.forward` directly without image embeds; running pipelines that forgot `ip_adapter_image`; custom sampling loops that enable IP-Adapter weights but never compute image embeddings.","solutions":["Pass `added_cond_kwargs={'image_embeds': image_embeds}` where image_embeds come from `pipe.prepare_ip_adapter_image_embeds(...)`","Detach/disable the IP-Adapter (`set_ip_adapter_scale(0)` or unload) if image prompting is not needed","Keep using the pipeline API, which computes and passes the embeds automatically"],"exampleFix":"// before\nunet(sample, t, encoder_hidden_states=text_emb, added_cond_kwargs={})\n// after\nimage_embeds = pipe.prepare_ip_adapter_image_embeds(ip_adapter_image, None, device, 1, False)[0]\nunet(sample, t, encoder_hidden_states=text_emb, added_cond_kwargs={'image_embeds': image_embeds})","handlingStrategy":"validation","validationCode":"if getattr(unet.config, 'encoder_hid_dim_type', None) == 'ip_image_proj' and not (added_cond_kwargs and 'image_embeds' in added_cond_kwargs):\n    raise ValueError(\"IP-Adapter UNet requires added_cond_kwargs={'image_embeds': ...}\")","typeGuard":"def has_image_embeds(added_cond_kwargs) -> bool:\n    return isinstance(added_cond_kwargs, dict) and 'image_embeds' in added_cond_kwargs","tryCatchPattern":"try:\n    out = unet(sample, t, emb, added_cond_kwargs=ackw)\nexcept ValueError as e:\n    if 'ip_image_proj' in str(e):\n        ackw = {'image_embeds': ip_embeds}; out = unet(sample, t, emb, added_cond_kwargs=ackw)\n    else: raise","preventionTips":["After loading an IP-Adapter, always use `prepare_ip_adapter_image_embeds` before direct unet calls","Or pass `ip_adapter_image` to the pipeline instead of calling unet.forward yourself","Unload/scale-to-zero the IP-Adapter when not using image prompting"],"tags":["diffusers","unet","ip-adapter","missing-argument","conditioning"],"backgroundTag":"missing-required-argument","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}