{"record":{"id":"2241d0d14b5c4e3b","repo":"invoke-ai/InvokeAI","slug":"unsupported-controlnet-type-for-image-preprocessin","errorCode":null,"errorMessage":"Unsupported controlnet type for image preprocessing.","messagePattern":"Unsupported controlnet type for image preprocessing\\.","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/hidiffusion/hidiffusion.py","lineNumber":594,"sourceCode":"                    for image_ in control_image:\n                        image_ = self.prepare_image(\n                            image=image_,\n                            width=width,\n                            height=height,\n                            batch_size=batch_size * num_images_per_prompt,\n                            num_images_per_prompt=num_images_per_prompt,\n                            device=device,\n                            dtype=controlnet.dtype,\n                            do_classifier_free_guidance=self.do_classifier_free_guidance,\n                            guess_mode=guess_mode,\n                        )\n\n                        images.append(image_)\n\n                    control_image = images\n                    height, width = image[0].shape[-2:]\n                else:\n                    raise AssertionError(\"Unsupported controlnet type for image preprocessing.\")\n            # 5. Prepare timesteps\n            self.scheduler.set_timesteps(num_inference_steps, device=device)\n            if image is not None:\n                timesteps, num_inference_steps = self.get_timesteps(num_inference_steps, strength, device)\n                latent_timestep = timesteps[:1].repeat(batch_size * num_images_per_prompt)\n            else:\n                timesteps = self.scheduler.timesteps\n            self._num_timesteps = len(timesteps)\n\n            # 6. Prepare latent variables\n            if image is not None:\n                # image-to-image controlnet\n                latents = self.prepare_latents(\n                    image,\n                    latent_timestep,\n                    batch_size,\n                    num_images_per_prompt,\n                    prompt_embeds.dtype,","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/hidiffusion/hidiffusion.py#L576-L612","documentation":"Same guard as errorIndex 948 but for the input image preprocessing path: HiDiffusion only knows how to prepare images for its supported controlnet types. An unrecognized controlnet object in the image-preprocessing branch raises AssertionError because it cannot determine the correct image sizing/batching.","triggerScenarios":"Running the HiDiffusion pipeline with img2img/strength where controlnet is an unsupported class — custom controlnets, wrapper objects, or classes renamed across diffusers versions failing the isinstance checks.","commonSituations":"diffusers upgrades changing ControlNetModel/MultiControlNetModel class locations; integrating community pipelines with bespoke controlnet classes; passing controlnet=None into a branch that expects a concrete type.","solutions":["Use a supported diffusers ControlNetModel (or MultiControlNetModel) instance","Update diffusers so class hierarchy matches HiDiffusion's isinstance checks","Pre-resize and batch your input image yourself and adapt the pipeline call to skip this path","Pin the diffusers version tested with HiDiffusion"],"exampleFix":"// before\ncontrolnet = MyControlNetWrapper(base_model)\nimage = pipeline(..., controlnet=controlnet).images[0]\n// after\nfrom diffusers.models.controlnet import ControlNetModel\ncontrolnet = ControlNetModel.from_pretrained(base_model)\nimage = pipeline(..., controlnet=controlnet).images[0]","handlingStrategy":"type-guard","validationCode":"from diffusers.models.controlnet import ControlNetModel\nassert isinstance(controlnet, ControlNetModel), f\"unsupported controlnet for image preprocessing: {type(controlnet)}\"","typeGuard":"def is_supported_controlnet(c) -> bool:\n    from diffusers.models.controlnet import ControlNetModel\n    return isinstance(c, ControlNetModel)","tryCatchPattern":"try:\n    result = pipeline(..., controlnet=controlnet)\nexcept AssertionError as e:\n    if \"Unsupported controlnet type\" in str(e):\n        raise TypeError(\"HiDiffusion supports diffusers ControlNetModel only\") from e\n    raise","preventionTips":["Use stock diffusers ControlNetModel/MultiControlNetModel with HiDiffusion","Pin diffusers versions in CI","Pre-resize images manually only if you bypass the supported path knowingly"],"tags":["hidiffusion","controlnet","unsupported-value","preprocessing"],"backgroundTag":"unsupported-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}