invoke-ai/InvokeAI · error · AssertionError

Unsupported controlnet type for image preprocessing.

Error message

Unsupported controlnet type for image preprocessing.

What it means

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.

Source

Thrown at invokeai/backend/hidiffusion/hidiffusion.py:594

                    for image_ in control_image:
                        image_ = self.prepare_image(
                            image=image_,
                            width=width,
                            height=height,
                            batch_size=batch_size * num_images_per_prompt,
                            num_images_per_prompt=num_images_per_prompt,
                            device=device,
                            dtype=controlnet.dtype,
                            do_classifier_free_guidance=self.do_classifier_free_guidance,
                            guess_mode=guess_mode,
                        )

                        images.append(image_)

                    control_image = images
                    height, width = image[0].shape[-2:]
                else:
                    raise AssertionError("Unsupported controlnet type for image preprocessing.")
            # 5. Prepare timesteps
            self.scheduler.set_timesteps(num_inference_steps, device=device)
            if image is not None:
                timesteps, num_inference_steps = self.get_timesteps(num_inference_steps, strength, device)
                latent_timestep = timesteps[:1].repeat(batch_size * num_images_per_prompt)
            else:
                timesteps = self.scheduler.timesteps
            self._num_timesteps = len(timesteps)

            # 6. Prepare latent variables
            if image is not None:
                # image-to-image controlnet
                latents = self.prepare_latents(
                    image,
                    latent_timestep,
                    batch_size,
                    num_images_per_prompt,
                    prompt_embeds.dtype,

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Use a supported diffusers ControlNetModel (or MultiControlNetModel) instance
  2. Update diffusers so class hierarchy matches HiDiffusion's isinstance checks
  3. Pre-resize and batch your input image yourself and adapt the pipeline call to skip this path
  4. Pin the diffusers version tested with HiDiffusion

Example fix

// before
controlnet = MyControlNetWrapper(base_model)
image = pipeline(..., controlnet=controlnet).images[0]
// after
from diffusers.models.controlnet import ControlNetModel
controlnet = ControlNetModel.from_pretrained(base_model)
image = pipeline(..., controlnet=controlnet).images[0]
Defensive patterns

Strategy: type-guard

Validate before calling

from diffusers.models.controlnet import ControlNetModel
assert isinstance(controlnet, ControlNetModel), f"unsupported controlnet for image preprocessing: {type(controlnet)}"

Type guard

def is_supported_controlnet(c) -> bool:
    from diffusers.models.controlnet import ControlNetModel
    return isinstance(c, ControlNetModel)

Try / catch

try:
    result = pipeline(..., controlnet=controlnet)
except AssertionError as e:
    if "Unsupported controlnet type" in str(e):
        raise TypeError("HiDiffusion supports diffusers ControlNetModel only") from e
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/2241d0d14b5c4e3b. Report an issue: GitHub.