Nodes/ComfyUI-TinyBee/Florence2 Caption Data Parser
ComfyUI Node

Florence2 Caption Data Parser

Turn Florence2's detection JSON into a mask, a box, and a center point

By TinyBeeman·Created about a year ago·Updated 10 days ago· 1
Florence2 Caption Data Parser
  • data
  • image
  • mask
  • tinyrect
  • empty
  • center_x
  • center_y
  • left_flush
  • top_flush
  • right_flush
  • bottom_flush
include
exclude
AllowEmptyfalse

Florence2 is Microsoft's tiny, MIT-licensed vision model, and the community's default lightweight captioner. What's less talked about is that the same model does grounding: you prompt it with a phrase and it comes back with the bounding boxes of where that phrase appears, packaged as a JSON payload of bboxes and labels. That payload is powerful and deeply inconvenient - it's JSON, not pixels. Florence2 Caption Data Parser is the node that makes it usable: it rasterizes those boxes into a mask, computes the enclosing rectangle, and hands you the geometry you actually want.

Give it the JSON, the image, and a comma-separated list of labels, and it draws every matching box onto a mask. That's the core mechanism - and it's what turns "describe the region in words" into a mask you can feed an inpaint or a detailer, which is the whole promptable-masking pattern from the detection/masking docs.

The inputs and outputs that matter

  • data - the Florence2 grounding JSON, on the pack's JSON socket type.
  • image - the source image (used for mask dimensions).
  • include - comma-separated labels to keep, e.g. face, hand. Case-insensitive, whitespace-tolerant.
  • exclude - comma-separated labels to subtract. Two-pass design: build the included mask, then carve out excluded regions.
  • AllowEmpty - the sneaky one. The label in the UI is "Allow Empty" / "Fallback to Full Image". When nothing matches your include list and this is off (default), the node falls back to a full-image mask so downstream crop/detail nodes still get something sensible instead of a blank mask.

The outputs are the treasure chest: mask (the rasterized region), tinyrect (its bounding box), empty (whether nothing matched), center_x/center_y (the region's centroid), and four *_flush booleans reporting whether the region touches the left/top/right/bottom image edges. That flush set is genuinely useful - an edge-touching region can't be cropped-and-detailled without growing outward, which is exactly the problem Change Rect Aspect and Crop/Grow Image to Bounds (same pack) are built to solve.

Where it sits in a pipeline

The typical chain: Florence2 node outputs grounding JSON → this parser → tinyrect into a crop or Rect To Mask for an inpaint region. Because Florence2 is MIT-licensed and runs on modest hardware, the whole detect-and-refine loop is cheap enough to run unattended on a batch. It lives in 🐝TinyBee/Util, alongside Combine Florence2 Caption Data for merging several payloads.

Install and gotchas

Standard TinyBee install - ComfyUI Manager → "ComfyUI-TinyBee", or:

cd ComfyUI/custom_nodes
git clone https://github.com/TinyBeeman/ComfyUI-TinyBee

then restart. Note what you are not installing here: this node has no model. Florence2 itself lives in its own pack (the Kijai or official ComfyUI node that produces the JSON) - TinyBee only parses what the model already returned. The one real gotcha is the fallback: if your include list misses (a label mismatch, a typo, the model failing to find the phrase), you'll silently get a full-image mask rather than an error. That's usually the right failure mode, but it can look like the parser "isn't working" when it's actually your include string that's off. Check empty and tinyrect when results look wrong.

Category🐝TinyBee/Util

Inputs (5)

NameTypeDefaultDescription
dataJSON
imageIMAGE
includeSTRING
excludeSTRING
AllowEmptyBOOLEANfalse

Outputs (9)

NameTypeDescription
maskMASK
tinyrectTINYRECT
emptyBOOLEAN
center_xINT
center_yINT
left_flushBOOLEAN
top_flushBOOLEAN
right_flushBOOLEAN
bottom_flushBOOLEAN