{"record":{"id":"7eb2640e69a997a5","repo":"invoke-ai/InvokeAI","slug":"self-class-has-the-config-param-encoder-hid","errorCode":null,"errorMessage":"{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`","messagePattern":"(.+?) 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`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/hidiffusion/hidiffusion.py","lineNumber":1131,"sourceCode":"                    raise ValueError(\n                        f\"{self.__class__} has the config param `addition_embed_type` set to 'image_hint' which requires the keyword arguments `image_embeds` and `hint` to be passed in `added_cond_kwargs`\"\n                    )\n                image_embs = added_cond_kwargs.get(\"image_embeds\")\n                hint = added_cond_kwargs.get(\"hint\")\n                aug_emb, hint = self.add_embedding(image_embs, hint)\n                sample = torch.cat([sample, hint], dim=1)\n\n            emb = emb + aug_emb if aug_emb is not None else emb\n\n            if self.time_embed_act is not None:\n                emb = self.time_embed_act(emb)\n\n            if self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == \"text_proj\":\n                encoder_hidden_states = self.encoder_hid_proj(encoder_hidden_states)\n            elif self.encoder_hid_proj is not None and self.config.encoder_hid_dim_type == \"text_image_proj\":\n                # 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                    )","sourceCodeStart":1113,"sourceCodeEnd":1149,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/hidiffusion/hidiffusion.py#L1113-L1149","documentation":"When the UNet has an `encoder_hid_proj` with `encoder_hid_dim_type='text_image_proj'` (Kandinsky 2.1), `encoder_hidden_states` must be combined with image embeddings supplied via `added_cond_kwargs['image_embeds']` before being consumed by downstream attention. The projection needs both text and image embeds, so a missing `image_embeds` raises immediately.","triggerScenarios":"Calling forward on a Kandinsky 2.1 UNet whose `encoder_hid_dim_type == 'text_image_proj'` without `added_cond_kwargs={'image_embeds': ...}`.","commonSituations":"Feeding raw text embeddings into a Kandinsky 2.1 UNet without its ImageTextEmbedding projection inputs; reusing SD pipeline code for Kandinsky; calling `unet.forward` directly instead of going through `prior`/`decoder` pipelines that assemble embeddings.","solutions":["Pass `added_cond_kwargs={'image_embeds': image_embeds}` (output of the Kandinsky image encoder) to forward","Ensure `text_embeds`/`encoder_hidden_states` match the shapes the `TextImageProjection` expects","If only text conditioning is needed, use a UNet with `encoder_hid_dim_type=None` or `'text_proj'`"],"exampleFix":"// before\nunet(sample, t, encoder_hidden_states=text_emb, added_cond_kwargs={})\n// after\nunet(sample, t, encoder_hidden_states=text_emb,\n     added_cond_kwargs={'image_embeds': image_embeds})","handlingStrategy":"validation","validationCode":"if getattr(unet.config, 'encoder_hid_dim_type', None) == 'text_image_proj' and not (added_cond_kwargs and 'image_embeds' in added_cond_kwargs):\n    raise ValueError(\"text_image_proj 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 'image_embeds' in str(e):\n        ackw = {'image_embeds': image_embeds}; out = unet(sample, t, emb, added_cond_kwargs=ackw)\n    else: raise","preventionTips":["Read `encoder_hid_dim_type` from config after loading Kandinsky checkpoints","Route Kandinsky inference through its decoder pipeline","Assemble encoder kwargs in one helper keyed on encoder_hid_dim_type"],"tags":["diffusers","unet","kandinsky","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"}