﻿# Stable Diffusion inpainting channels: a mask is part of the denoiser input

Trace the dedicated Stable Diffusion inpainting denoiser input from noisy latents, mask, and masked-image latents, and distinguish it from a base-model blending path.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-stable-diffusion-inpaint-nine-channel-input/
Language: en

## Start with the latent representation

The [latent diffusion paper](https://arxiv.org/abs/2112.10752) explains generation in an autoencoder's compressed space. A denoising latent is therefore different from ordinary image color channels. In a dedicated Stable Diffusion inpainting path, the model receives additional information about the editing region and the visible source. Understanding those fields matters when converting checkpoints, constructing custom inputs, or deciding whether a base text-to-image model is interchangeable with a specialized inpainting artifact.

## Trace the channel concatenation

The [pipeline source](https://raw.githubusercontent.com/huggingface/diffusers/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py) distinguishes a 9-channel denoiser input from a 4-channel base path. The dedicated input combines 4 noisy-latent channels, 1 mask channel, and 4 masked-image latent channels. These are concatenated along the channel axis while retaining compatible batch and spatial dimensions. The mask does not become a text embedding, and the masked-image latent is not another independent generated sample.

## Do not repair a mismatch by relabeling configuration

Imagine a conversion that loads ordinary base weights but changes in_channels to match the inpainting input. Matching the declared dimension does not supply learned weights for interpreting the additional fields. The system needs a compatible model and correctly ordered conditions. Check tensor shape and checkpoint architecture together before investigating visual quality. A pipeline accepting a filename or a converted configuration is not evidence that the intended dedicated inpainting computation has been assembled.

## Distinguish the base-model alternative

The same implementation supports a separate base-input path that blends source latents through the denoising process. That is a different mechanism from concatenating a mask and masked-image representation into a dedicated denoiser. The [inpainting API documentation](https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion/inpaint) provides the application interface, but the selected model determines the internal path. Record which mechanism ran instead of describing both as equivalent merely because the user supplied an image and mask.

## Validate the semantic fields

Preserve source preprocessing, mask polarity, latent scaling, field order, and the selected model revision. Test a small known edit and inspect both changed and preserved regions. Existing guides on [tensor axes](/journal/tensor-axes-batch-sequence-hidden/) and [artifact validation](/journal/safetensors-artifact-validation/) provide background. The dedicated inpainting contract connects architecture with input meaning: all fields must align spatially and correspond to the learned channel interface, while a base-model blending implementation must be documented as its own execution path.
