GR Mask Create Random
A seeded random mask, sized as a fraction of the canvas
- MASK
Sometimes you don't want a mask derived from an image at all - you just want a random region to inpaint, test against, or use as a stand-in for "something changed here." This node does exactly that: give it a canvas size and a size fraction, and it generates a random mask region seeded for reproducibility. No image input required.
How it works
It's a small, purpose-built node. height and width set the canvas the mask is generated on - match these to your actual working resolution or the mask won't line up when you composite it back. mask_size (0.01 to 1) controls roughly how much of that canvas the random region covers, as a fraction rather than a pixel count, so it scales sensibly if you change resolution later. seed makes the "random" part reproducible - same seed, same canvas size, same mask, every time.
Where this is actually useful: stress-testing an inpainting workflow against masks you didn't hand-pick (so you're not unconsciously testing only on easy cases), generating placeholder masks while you're building out a graph before real segmentation is wired in, or producing randomized "damage" regions for augmentation-style workflows where you want variety without manually drawing a new mask each time.
The inputs and outputs that matter
heightandwidth- the canvas dimensions the mask is generated on. Get these wrong relative to what you're actually compositing against and the mask will be the wrong scale or won't align.mask_size(0.01-1) - how much of the canvas the random region covers, as a fraction. Small values on a large canvas can produce a mask small enough to be easy to miss if you're just eyeballing a preview - check the actual output rather than assuming it worked.seed- reproducibility. Change it to get a different random region at the same size and canvas; keep it fixed to get the same one back.
One output: MASK, ready to feed straight into an inpainting node or anywhere else a mask is expected.
How to install it
Via ComfyUI Manager, search GraftingRayman. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/GraftingRayman/ComfyUI_GraftingRayman
Restart. Like every node in this pack, it needs OpenAI's CLIP installed separately or the pack fails to import - portable ComfyUI: .\python_embeded\python.exe -m pip install git+https://github.com/openai/CLIP.git; system Python: pip install git+https://github.com/openai/CLIP.git.
Common issues & troubleshooting
Pack doesn't load. Check your startup console for the CLIP import error and run the pip command above - this is the same root cause across every node in this pack, this one included even though it has nothing to do with vision models itself.
Mask seems to have no effect downstream. With mask_size set low on a large canvas, the generated region can be small enough that its effect on the final composite is negligible. Bump mask_size up if you want a more noticeable region.
Mask doesn't align with your image. height/width on this node are independent of whatever image you're compositing against - they don't read dimensions from an upstream image automatically. Set them to match your actual working resolution.
Same seed gives a different-looking mask after changing canvas size. Expected - the mask is generated relative to height/width, so changing the canvas changes the random result even with an identical seed.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| height | INT | — | |
| width | INT | — | |
| mask_size | FLOAT | 0.01–1 | — |
| seed | INT | 427950096951925100000000000000–999999999999999 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |