Nodes/ComfyUI_InternVL3/BBoxes与XYXY互换
ComfyUI Node

BBoxes与XYXY互换

The BBox Translator That Ends the XYXY-vs-BBOXES Format Fight

By 1H-hobit·Created about a year ago·Updated 11 months ago· 2
BBoxes与XYXY互换
  • input_bboxes
  • input_bbox
  • output_BBOXES
  • output_BBOX_xyxy
  • output_BBOX_xywh
  • valid_count
  • invalid_count
  • conversion_log
convert_modeBBOXES_to_XYXY
index
batch_modetrue
invalid_threshold0
keep_invalid_boxestrue

Object detection in ComfyUI has a format problem, and it's not the coordinates - it's the container. Florence2 and InternVL detection nodes hand you a BBOXES structure: a list of batches, each batch a list of [x1, y1, x2, y2] boxes. Plenty of downstream nodes - mask croppers, SAM feeds, regional conditioning - want a plain flat BBOX instead, and some want xywh (with width and height) so they can compute crop rectangles. That mismatch is where BBOXES_XYXY_Converter lives. It's a small utility from the 1H-hobit/ComfyUI_InternVL3 pack that reshuffles boxes between those formats, filters out the junk, and tells you what it did.

What it actually does

Pick a direction with convert_mode:

  • BBOXES_to_XYXY - flatten a batch structure into flat lists. Needs input_bboxes.
  • XYXY_to_BBOXES - rebuild the batch structure from a flat input_bbox. Each box becomes its own one-box batch.

That second direction is the useful one for feeding region or SAM nodes, which often expect one box per batch slot.

The converter is honest about its scope: the coordinates coming in are already xyxy. It's not flipping axes or rescaling anything - it restructures, computes xywh (w = x2 - x1, h = y2 - y1), and counts.

The inputs that matter

  • convert_mode - direction, listed above.
  • index - a string. Leave empty for all boxes, or pick specific ones with comma-separated numbers like "0,2,5". Indexes are applied per batch.
  • invalid_threshold - a box counts as invalid when both x1 and y1 are at or below this value (default 0). That's the tell-tale [0,0,...] padding box that detection models emit when they find nothing. Pair it with keep_invalid_boxes (default on) to drop or keep those empties.

Two modes want two different inputs: supply both input_bboxes and input_bbox at once and you get an error - same if you feed the wrong one for the mode. The error text lives in the log, not on the canvas.

Outputs

Six of them, and they cover every format a downstream node could want: output_BBOXES (original batch structure), output_BBOX_xyxy (flat), output_BBOX_xywh (flat, with width/height), plus valid_count and invalid_count. Then there's conversion_log - a STRING the author clearly wrote for debugging. It's chatty and in Chinese, but when a conversion silently returns empty, that log is where the actual error message is. Start there before tearing your hair out.

Install

It ships in the InternVL3 pack, so you get the whole thing at once. ComfyUI Manager → Install Custom Nodes → search ComfyUI_InternVL3, or:

cd ComfyUI/custom_nodes
git clone https://github.com/1H-hobit/ComfyUI_InternVL3.git

Restart ComfyUI. One thing to know: the repo ships no requirements.txt, so nothing is auto-installed - the pack leans on whatever torch/transformers your environment already has. The heavier part of this pack is the InternVL Model Loader (it pulls InternVL3-1B from HuggingFace into ComfyUI/models/LLM and needs bitsandbytes for quantization). This node needs none of that - it's pure list math, and works even if you never load a model.

Where people get burned

Coordinates are cast to int on the way through. If your detection node emits normalized 0–1 boxes, they'll truncate to 0 and everything will look broken - convert to pixels upstream first. And remember it restructures, it doesn't transform: if two nodes disagree about the meaning of coordinates, no converter fixes that. For the format disagreement, though, this is the one I'd grab over writing a Python node, if only because the log tells you exactly what it did.

Categoryinternvl

Inputs (7)

NameTypeDefaultDescription
convert_modeCOMBOBBOXES_to_XYXY2 options: BBOXES_to_XYXY, XYXY_to_BBOXES
indexSTRING
batch_modeBOOLEANtrue
invalid_thresholdINT00–10
keep_invalid_boxesBOOLEANtrue
input_bboxesoptBBOXES
input_bboxoptBBOX

Outputs (6)

NameTypeDescription
output_BBOXESBBOXES
output_BBOX_xyxyBBOX
output_BBOX_xywhBBOX
valid_countINT
invalid_countINT
conversion_logSTRING