ποΈ Gemini Mask Select
Grab one mask out of a batch, with a preview to boot
- masks
- mask
- preview
- selected_index
- batch_size
Gemini Mask Select is the MASK counterpart of Gemini Image Select: pick one mask out of a batch by index. Batch of seven segmentation masks, you want the one at position 3 - index of 3, out comes exactly that mask. Local, no API, no key.
Where it earns its keep is the workflow where a batch of masks arrives and only one matters. That's the whole pattern of the pack's local half: Gemini Segmentation produces a mask per object, Gemini Separate Mask Components splits a mask into per-blob masks, and then you need one of them - the biggest face, the second object from the left - to feed a crop, an inpaint, or a compositor. Mask Select is the picking tool.
How it works
The input is masks (a MASK batch; index 0 is the first) plus index. Out-of-range behavior matches Image Select exactly: out_of_range is clamp (return the last mask) or wrap (index 5 in a batch of 3 β mask 2). And like its image sibling it surfaces the real batch_size as an output, so an upstream index source can be clamped to the true range instead of guessing.
The one trick this node has that Image Select doesn't: a preview output. Mask tensors are invisible to the eye, and every other mask node in this pack forces you to add a separate preview node or convert to image to see anything. Mask Select emits preview - the selected mask rendered as a white-on-black IMAGE, ready to wire into a Preview Image or Save Image. For a node whose whole job is "which one did I just grab," that built-in eyeball check is the difference between debugging masks all afternoon and just looking.
Outputs: mask (the selected mask as a single-item (1, H, W) batch), preview, selected_index (the resolved index after clamp/wrap), batch_size.
When to reach for it
Any place you've got a batch of masks and a selector. The cleanest setup pairs it with Separate Mask Components: split a mask into blobs sorted by area, then set index from a widget and you have "the Nth largest blob as a mask." Add Gemini Mask Crop after it and you're cropping the image at exactly that blob. If your index is a fixed constant, you might be better off filtering upstream (Separate Mask Components' min_area/max_components do a lot of that for you); Mask Select shines when the index is driven by something dynamic.
Install
Same pack, same story: ComfyUI Manager search "ComfyUI_Gemini", or git clone https://github.com/aarnoatchi/ComfyUI_Gemini into custom_nodes and pip install -r requirements.txt. No scipy, no key. Restart and it's under AI/Image Analysis/Google.
The only real confusion to avoid is the batch/list split, which this pack is honest about in its README: Mask Select works on a batch - one MASK tensor where every mask shares dimensions. That's what Segmentation, Separate Mask Components, and Mask Crop all emit, so you're set. If you ever find yourself holding masks of different sizes, that's a list situation, and you'll need a list-aware picker instead of this node.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | A mask batch. Index 0 is the first mask, 1 the second, etc. | |
| index | INT | 00β4095 | Which mask to pick from the batch (mask 0, mask 1, ...). |
| out_of_rangeopt | COMBO | clamp | What to do when index is past the end of the batch: clamp β return the last available mask wrap β wrap around (index 5 in a batch of 3 β mask 2) |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| mask | MASK | β |
| preview | IMAGE | β |
| selected_index | INT | β |
| batch_size | INT | β |