invoke-ai/InvokeAI · error · ValueError
Initial latents are required when using an inpaint mask (ima
Error message
Initial latents are required when using an inpaint mask (image-to-image inpainting)
What it means
An inpaint mask requires the original image's latents so the extension can composite inpainted regions back against known content. If a mask is present but init_latents is None, InvokeAI raises this ValueError because inpainting is impossible without reference latents.
Source
Thrown at invokeai/app/invocations/anima_denoise.py:640
s_0 = sigmas[0]
latents = s_0 * noise + (1.0 - s_0) * init_latents
else:
latents = init_latents
else:
if self.denoising_start > 1e-5:
raise ValueError("denoising_start should be 0 when initial latents are not provided.")
assert noise is not None
latents = noise
if total_steps <= 0:
return latents.squeeze(2)
# Prepare inpaint extension
inpaint_mask = self._prep_inpaint_mask(context, latents.squeeze(2))
inpaint_extension: AnimaInpaintExtension | None = None
if inpaint_mask is not None:
if init_latents is None:
raise ValueError("Initial latents are required when using an inpaint mask (image-to-image inpainting)")
assert noise is not None
inpaint_extension = AnimaInpaintExtension(
init_latents=init_latents.squeeze(2),
inpaint_mask=inpaint_mask,
noise=noise.squeeze(2),
shift=ANIMA_SHIFT,
)
step_callback = self._build_step_callback(context)
# Initialize scheduler driver if not using built-in Euler.
use_scheduler = self.scheduler != "euler"
driver: AnimaSchedulerDriver | None = None
if use_scheduler:
driver = AnimaSchedulerDriver(
scheduler_name=self.scheduler,
sigmas=sigmas,
steps=self.steps,View on GitHub (pinned to 0b6a024f2f)
Solutions
- Provide an init image so init_latents can be encoded (img2img inpainting).
- Remove or disconnect the inpaint mask if you truly want unconditional txt2img generation.
- Verify upstream nodes actually emit the init image/latents into the denoise node.
Example fix
// before denoise.mask = mask_field # no image input // after denoise.image = init_image_field # img2img inpainting // or remove the mask for txt2img
Defensive patterns
Strategy: validation
Validate before calling
if inpaint_mask is not None and init_latents is None:
raise ValueError("Inpainting requires an init image/latents") Try / catch
try:
output = invoker.invoke(denoise_invocation)
except ValueError as e:
if "inpaint mask" in str(e):
raise RuntimeError("Connect an init image or remove the mask before running") from e Prevention
- Require an image input whenever a mask is present in the workflow
- Disable mask nodes in pure txt2img graphs
- Validate graph edges (mask present => image edge present) before submission
When it happens
Trigger: Supplying an inpaint_mask to the Anima denoise invocation (mask detected by _prep_inpaint_mask) while running in pure txt2img mode with no initial latents.
Common situations: Using a canvas/mask workflow where the init image layer was removed or never rendered; thinking a mask alone is enough for inpainting; converting an img2img inpaint workflow to txt2img but keeping the mask.
Related errors
- denoising_start should be 0 when initial latents are not pro
- denoising_start should be 0 when initial latents are not pro
- Initial latents are required when using an inpaint mask (ima
- Mode '{request.mode}' requires a mask image for {request.mod
- No external provider config fields provided
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/cf47d95337ddc12e.
Report an issue: GitHub.