BMAB Detect And Mask
Turning an object detector into a usable mask
- image
- mask
This is the detection half of BMAB's detect-crop-refine machinery - the node that answers "where is the thing I care about in this image," and hands you back a mask you can feed anywhere a mask is expected, most naturally into BMAB Detail Anything.
What it is and why you'd reach for it
You give it an image and a detection model, and it finds whatever that model was trained to find, returning a MASK covering the detected region(s). This is the same pattern as GroundingDINO-plus-SAM pipelines elsewhere in the ComfyUI ecosystem: a text-prompted or class-based detector finds the object, and the mask it produces feeds a downstream refinement or compositing step rather than being the end product itself. In BMAB's case, the obvious next stop is BMAB Detail Anything, but nothing stops you from wiring this mask into a stock ComfyUI inpainting node either.
Where this earns its place over manually painting a mask: batch processing (running the same detection across many images without touching each one by hand), or any workflow where you don't know in advance exactly where the target region will land.
How it works
Per the README, BMAB's object detection runs on Hugging Face's transformers library, which has shipped a Grounding DINO implementation since v4.40.0 - no separate model install needed for that specific detector, it comes along with the dependency BMAB already requires. The dilation setting grows the raw detected mask outward slightly before it's returned, which matters for whatever consumes it downstream: a mask that hugs the detected box too tightly tends to leave a visible seam once something gets resampled or pasted into it.
Inputs and outputs
- image (required) - the image to run detection on.
- model (required, dropdown) - the detection model to use. This dropdown is populated from whatever detection models you have installed; if it's empty, you haven't added one yet.
- dilation (default 4, range 4–128) - how much to grow the detected region before returning it as a mask.
Output: a single mask.
Installing it
Through ComfyUI Manager: search comfyui_bmab, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/portu-sim/comfyui_bmab.git
cd comfyui_bmab
pip install -r requirements.txt
The README is explicit that Grounding DINO detection rides on transformers>=4.40.0 and needs no separate install - it should already be satisfied by BMAB's own requirements.txt. This node doesn't need comfyui_controlnet_aux or ComfyUI_IPAdapter_plus.
Common issues
transformersversion mismatches breaking detection outright. This is a real, reported problem, not a hypothetical one - people have hit an error along the lines ofGroundingDinoProcessor.post_process_grounded_object_detection() got an unexpected keyword argument 'box_threshold'when running BMAB's detection nodes, which is a signature mismatch between thetransformersversion installed and what BMAB's code expects. If detection nodes throw an error mentioningbox_thresholdor a similar unexpected-keyword-argument complaint, the fix is matching yourtransformersversion to what's pinned incomfyui_bmab/requirements.txtrather than assuming the latest release is safe - a newertransformerscan silently change a method's signature out from under a pack that was written against an older one.- Empty
modeldropdown. Means no detection model is installed where BMAB expects to find one - check your setup against the README's model-file guidance before assuming the node itself is broken. - Detected mask too tight, causing a visible seam downstream. Bump
dilationup before troubleshooting further downstream - a slightly larger mask blends more forgivingly into whatever refinement or paste operation follows.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | COMBO | 0 options: | |
| dilation | INT | 44–128 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |