Mask Batch
Stack up to four masks into one batch — Mask Batch
- masks_a
- masks_b
- masks_c
- masks_d
- masks
A lot of the node packs that do masked detailing - the detect-mask-inpaint loops from the KB's masking doc - want masks in batches. One mask per frame of a video, one mask per image in a folder pass. But individual mask ops, SAM, segmenters, they hand you single masks one at a time. wcx_MaskBatch is the joiner: up to four mask inputs in, one batched MASK out.
The mechanism is uncomplicated: it stacks whatever mask inputs are actually connected into a single tensor along the batch dimension, and adds a channel dimension on top (which is the shape a lot of downstream mask consumers expect). The interesting safety net is the dimension check it runs first - every input mask must have the same height and width, and if they don't, it raises an error naming the mismatched ones instead of silently producing garbage. The error message itself is worth a knowing nod: it literally says "WAS Mask Batch Warning," a leftover from the WAS Node Suite lineage this pack clearly draws from.
Inputs are masks_a, masks_b, masks_c, masks_d - all optional, so you can join two, three, or four. Output is masks. None of the sockets care how many frames each input carries; it's per-batch stacking, so masks_a could itself be a 5-frame batch and masks_b a 3-frame batch and you get an 8-frame result - as long as every individual frame is the same resolution.
Gotchas:
- Same resolution or nothing. That dimension check is strict and it's the whole contract. Masks from different sources rarely match out of the box; if you're joining masks from different models, resize them to a common size first.
- Empty inputs are silently skipped. Unconnected sockets just don't participate. But if all of them are empty, it raises an error - "at least one input mask must be provided." No graceful no-op there.
- The channel dimension appears. Output masks come out shaped
(batch, 1, H, W)after theunsqueeze. Most ComfyUI mask nodes handle that fine, but if a downstream node complains about rank, this is where the extra dimension came from.
Install is the pack's standard light path - no requirements file, no model downloads:
# ComfyUI Manager: search "ComfyUI-Practical-Tools" → Install → restart
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools
# restart ComfyUI
It's a workhorse utility, not a headline feature - but every batch detailing workflow I've built ends up needing exactly this glue step, and this one has the dimension check that saves you from silent misalignment.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| masks_aopt | MASK | — | |
| masks_bopt | MASK | — | |
| masks_copt | MASK | — | |
| masks_dopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | — |