Areas Generator
Random region masks on demand — no hand-painting required
- Areas Mask
AreasGenerator spits out a mask image filled with randomly placed zones - circles or rectangles, random sizes, scattered across a canvas you size. Same seed, same mask, every time. If you've ever hand-painted twenty masks for an inpainting test or a region-control experiment, you already know why that's worth a node.
It's one of the three tools in comfyUI-PL-data-tools, whose author describes the pack as "image data check, filtering and augmentation tools." This is the augmentation half. The natural uses: building training sets where the model has to learn to work around random masked regions (the masked-training style the KB's LoRA essay points at - paint masks so the loss ignores everything but the subject), reproducible regional conditioning for ControlNet/region experiments, or stress-testing an inpaint model by throwing the same image at a bunch of different random masks and watching where it breaks.
How it works
It's a tiny deterministic RNG script. np.random.seed(seed) resets numpy's global generator, then for each of num_of_zones it picks a shape, rolls a width and height from your min/max bounds, rolls an x/y position, and ORs the shape onto a zeroed bitmap. Circles are drawn with OpenCV's cv2.circle; rectangles are just blocks of ones. The result leaves as a torch tensor shaped [1, 1, H, W] - one single-channel image in a batch of one, typed IMAGE, under the output name Areas Mask.
The inputs that actually matter
Most of the nine inputs are self-explanatory, but here's what you'll touch:
image_width/image_height- canvas size in pixels.basic_shape-circleorrectangle.min_zone_width/max_zone_widthandmin_zone_height/max_zone_height- the size range each zone rolls from.num_of_zonesandseed- how many shapes, and the reproducibility dial.
Where people get burned
The defaults will crash it on the very first queue, and that's a real trap. min_zone_width and max_zone_width both default to 32, and the code rolls zone sizes with numpy.random.randint(min, max), which raises ValueError: low >= high when the bounds are equal. Same for height. So set every max strictly above its min before you hit Queue - something like 64 to 256. Second trap: keep zone sizes comfortably smaller than the canvas. Placement rolls randint(0, width - zone_width), so a zone as big as (or bigger than) the image blows up too. Third, and subtler: the output is an IMAGE-typed single-channel mask, not the MASK type most inpaint nodes expect - you may need a small conversion step depending on what you're wiring it into.
It's one mask per run, but since it's fully seed-reproducible you can generate as many as you want by calling it repeatedly with different seeds.
Install
There's no README in this repo, which is the first thing to know about the pack. Standard route: ComfyUI Manager → Install Custom Nodes → search comfyUI-PL-data-tools → Install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/PnthrLeo/comfyUI-PL-data-tools
then restart ComfyUI. The pack is tiny, MIT-licensed, and basically unknown in the wild - no community footprint to speak of. It also ships no requirements.txt, and its __init__ imports all three nodes up front. That matters here specifically: this node imports cv2 (OpenCV), which a stock ComfyUI install doesn't provide. Missing opencv means the whole pack fails to register, not just this node, and Manager can't auto-fix it because there's no requirements file. The fix is one line in your ComfyUI Python environment:
pip install opencv-python
torchvision, tqdm and Pillow are already part of a stock ComfyUI install, so opencv is genuinely the only gap. Once that's in, AreasGenerator is a solid little deterministic mask factory - nothing fancy, but it does exactly one thing and does it reproducibly.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image_width | INT | 1024 | — |
| image_height | INT | 1024 | — |
| basic_shape | COMBO | 2 options: circle, rectangle | |
| min_zone_width | INT | 32 | — |
| max_zone_width | INT | 32 | — |
| min_zone_height | INT | 32 | — |
| max_zone_height | INT | 32 | — |
| num_of_zones | INT | 10 | — |
| seed | INT | 42 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Areas Mask | IMAGE | — |