abyz22_RandomMask
A mask vending machine for inpainting experiments
- image
- image
- mask
If you're testing an inpainting setup, hand-drawing a mask for every experiment gets old fast. abyz22_RandomMask is the antidote: give it an image and it generates a random mask - circle, square, triangle, or a mix - at a random size, blurred by a random amount, optionally dilated or eroded. One queue roll, new mask, new repair challenge. It's the classic data-augmentation tool for mask-based inpainting, and it's also handy when you want a quick texture-repair stress test without opening the mask editor.
It's part of abyz22/image_control, the Impact Pack fork, where it feeds the pack's LaMa and body-mask nodes. Pure OpenCV/PIL geometry, no model involved.
Inputs that matter
image- used for the mask's dimensions (the mask is generated from scratch, not derived from the image content).shape-circle,square,triangle, orrandom(mixes them per mask).size-small,medium,big, orrandom, controlling the mask's footprint.multi_mask-multigenerates one mask per frame in the batch,singlegenerates one shared mask. This is the one you'll toggle for batch behavior.mask_min/mask_max(−0.1–1 / 0–1.1) - clamp the final mask values. Set both near 1 for crisp binary masks; a lowmask_maxsoftens everything.expand(−200–200, default 50) - positive dilates the mask, negative erodes it.blur-very_weakthroughvery_hardplusrandom, controlling Gaussian blur radius.seed- exists, but see the gotcha below.
Outputs: image (the mask repeated into 3 channels, IMAGE type) and mask (the single-channel MASK). They're the same data in two skins.
How it works
The node picks a random center and size, draws the chosen shape with OpenCV, optionally rotates it, then dilates/erodes per expand and Gaussian-blurs per blur, clamping values into mask_min/mask_max. That clamp is the part people miss: after heavy blur the mask gets re-thresholded against the clamps, so a low mask_max turns a fuzzy blur into a dim soft mask while a high one keeps the blob solid.
Install and the honest gotchas
cd ComfyUI/custom_nodes
git clone https://github.com/abyz22/image_control
or ComfyUI Manager → "image_control", restart. The pack adds openpyxl, pytorch-lightning, kornia to your environment.
The seed widget is decorative. The code re-seeds from the wall clock (torch.manual_seed(time.time())) on every run, so the same seed produces different masks every time - if you need a reproducible mask, generate one, save it, and reuse it rather than trusting seed. Also, mask placement is fully random across the whole frame, so masks can land half off the edge; that's fine for augmentation but confusing when one frame has no visible mask. For scattered multi-region holes, the pack's abyz22_makecircles is the sibling to reach for instead.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| multi_mask | BOOLEAN | true | — |
| shape | COMBO | circle | 4 options: circle, square, triangle, random |
| size | COMBO | medium | 4 options: small, medium, big, random |
| mask_min | FLOAT | 0.0-0.1–1 | — |
| mask_max | FLOAT | 1.00–1.1 | — |
| expand | INT | 50-200–200 | — |
| blur | COMBO | medium | 6 options: very_weak, weak, medium, hard, very_hard, random |
| seed | INT | 00–18446744073709550000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |