Masks to Patches
Pixel masks into the patch-level masks attention actually reads
- masks
- patch_masks
- h
- w
MasksToPatches is the pack's unit-converter. Diffusion models don't think in pixels - a Flux- or Chroma-family model works on patches, roughly one per 16×16 pixel block. So when you give the CharaConsist nodes a pixel-space mask of your subject, there's a mismatch between the units you're thinking in and the units attention operates in. This node bridges it: it takes your [N, H, W] pixel masks, downsamples them to patch resolution (h = H/16, w = W/16) with nearest-neighbor interpolation, and flattens the result into the patch-level masks the attention-masking nodes expect.
It also handles the batch shape. The target_count input (default 1) appends that many extra rows of all-ones padding to the output mask. Why ones? Those padded rows are the target images in a batched generation, and a target should be allowed to attend everywhere - the subject constraint applies to the references, not to what you're generating. Get target_count wrong and your batch either loses a target row or adds a phantom one, so it's the one knob worth double-checking.
Inputs and outputs
masks(MASK) - the pixel masks, one per subject.target_count(INT, default 1) - how many target images the padded rows are for.
Outputs: patch_masks (MASK) at patch resolution with the padding rows; h and w (INT) - the patch dimensions, which are handy for checking you got the expected resolution before you feed anything downstream. If you're wiring into BatchedMaskedReferenceGen, patch_masks is your source_patch_masks.
When to use it vs MaskToPatchMask
This is the multi-mask version. Feed it a batch of subject masks from SAM or ExtractAttn and it converts them all in one shot, with padding built in. MaskToPatchMask is the single-mask sibling with patch_size and threshold controls - use that one when you want to tune how a mask gets binarized at the patch level. MasksToPatches is more "take what SAM gave me and make it plumbable."
Install
ComfyUI Manager → search "Comfyui_CharaConsist", or git clone https://github.com/thatname/Comfyui_CharaConsist.git into custom_nodes, restart, find it under chara_consist. No pip deps, Flux/Chroma/Qwen-Image only - same as every node here.
Troubleshooting is mostly a shape problem. If your mask comes in at a resolution that doesn't divide cleanly by 16, the node truncates to whole patches and the subject mask edges get clipped - it won't error, it'll just lose the boundary. Keep masks at a multiple of 16 on both axes. And remember the output is patch-resolution, so if you preview it next to a pixel image it'll look blocky and small. That's correct. It's supposed to. The blockiness is the point.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | — | |
| target_count | INT | 1 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| patch_masks | MASK | — |
| h | INT | — |
| w | INT | — |