Nodes/ComfyUI-ZSNodes/Bounding Box Crop (ZS)
ComfyUI Node

Bounding Box Crop (ZS)

Type what you want, crop it out

By ZeroSpaceStudios·Created about a year ago·Updated about a year ago· 0
Bounding Box Crop (ZS)
  • image
  • paint_color
  • OUTPUT_IMAGE
  • ORIGINAL_WITH_BOXES
  • BBOX_INFO
  • MASK
prompt
dino_modelGroundingDINO_SwinT_OGC (694MB)
output_modeCrop
deviceAuto
threshold0.35
crop_modeFirst
padding10

GroundingDINO-based text-to-box detection in a single node. Instead of painting a mask or dragging a crop box by hand, you type "cat" - or "red apple", "person on the left" - and the node finds the boxes itself. What comes out is a crop of what it found, the original with red boxes drawn on it, and a binary mask of the region. That's the whole appeal: it turns "select this" into "name this."

This is the same GroundingDINO family that does half the targeted masking in the ecosystem - GroundingDINO finds the object, SAM turns it into a precise mask, and the pairing feeds inpainting and compositing (see background-removal.md). This node skips SAM and hands you the box plus a box-shaped mask directly, which is honestly enough for a lot of jobs: face crops for img2img, isolating one object to run through an upscaler, or yanking every "car" out of a street scene for a dataset.

How it works. On first use it downloads GroundingDINO weights - ~694MB for the SwinT model, ~938MB for SwinB - from the 1038lab HuggingFace repo into ComfyUI/models/grounding-dino/. After that, the detector runs your prompt against the image (it silently appends a period, which GroundingDINO likes), keeps every box whose confidence clears the threshold, and either crops or paints. The model stays cached per session, so the second run is fast.

Inputs that matter:

  • prompt - plain-language detection query, nothing fancy ("cat", "the red car").
  • output_mode - Crop extracts the object; Paint fills everything outside the box with paint_color, which is handy for prepping an inpaint.
  • crop_mode - First, Best (highest confidence), All (one output per detection, resized to a common size), or Merge (one box around everything).
  • threshold (default 0.35) - lower it if detections keep getting missed; raise it if you're chasing false positives.
  • padding (default 10px) - GroundingDINO boxes hug tight, so add more when the crop feeds a detail pass.

The other fields - dino_model, device, paint_color - are set-and-forget: bigger model for accuracy, Auto device, and the hex fill used in Paint mode.

Outputs. OUTPUT_IMAGE (the crops or painted image), ORIGINAL_WITH_BOXES (annotated original), BBOX_INFO (text with coordinates and confidence per box), and MASK (binary mask of the region).

Where people get burned:

  • The RuntimeError "GroundingDINO is not installed" - the groundingdino-py dependency is the fragile one. The pack's other node, Save Image, works fine without it; this one refuses to.
  • The first run looks like a hang while ~700MB downloads. It isn't.
  • If nothing clears the threshold you don't get an error - you get the input image passed through and BBOX_INFO reads "No objects detected". Lower the threshold or reword the prompt.
  • Batch trap: with First/Best/Merge, each image yields one crop, and crops of different sizes get concatenated into one tensor - mismatched sizes error downstream. Feed same-size images, or use All mode.

Install. ComfyUI Manager (search "ComfyUI-ZSNodes"), or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ZeroSpaceStudios/ComfyUI-ZSNodes
pip install -r requirements.txt

Then restart ComfyUI - it usually auto-installs any remaining deps on first load. Fair warning: this is a tiny one-commit pack with essentially no community footprint, and the README still has placeholder text. If you already run Impact Pack or ComfyUI-RMBG, you may already have better-maintained GroundingDINO nodes - this one is worth it mainly when you want the detection-and-crop in one node with no extra pack.

Categoryzsnodes/image

Inputs (9)

NameTypeDefaultDescription
imageIMAGE
promptSTRINGEnter text description of object to detect and crop
dino_modelCOMBOGroundingDINO_SwinT_OGC (694MB)GroundingDINO model for text-to-box detection
output_modeCOMBOCropCrop: extract the object, Paint: paint out everything else
deviceCOMBOAutoAuto: smart detection, CPU: force CPU, GPU: force GPU
thresholdoptFLOAT0.350.05–0.95Detection threshold (higher = more strict)
crop_modeoptCOMBOFirstHow to handle multiple detections
paddingoptINT100–200Padding around the bounding box in pixels
paint_coloroptCOLOR#000000Color to paint outside the bounding box (hex format)

Outputs (4)

NameTypeDescription
OUTPUT_IMAGEIMAGE
ORIGINAL_WITH_BOXESIMAGE
BBOX_INFOSTRING
MASKMASK