Nodes/ComfyUI-Florence-2/Florence2 Postprocess Single
ComfyUI Node

Florence2 Postprocess Single

One detection box → a mask, a label, and coordinates you can actually use

By spacepxl·Created 2 years ago·Updated about a year ago· 85
Florence2 Postprocess Single
  • F_BBOXES
  • mask
  • label
  • loc_string
  • width
  • height
  • x
  • y
index0

The Florence2 node hands you a blob of detections in its F_BBOXES output. This node is how you unwrap it: you point at one box by index, and out the other side comes a clean mask, the label, and the box's geometry. It's the difference between "the model found some things" and "give me the mask of thing number two."

Mechanically it's simple. F_BBOXES is a dict holding either bboxes/labels (from detection tasks) or polygons/labels (from segmentation tasks), plus the original image width and height. The node builds a binary mask from the box or polygon at the index you choose - white where the object is, black everywhere else, sized to the original image. For boxes it also produces a loc_string in Florence-2's location format: <loc_x1><loc_y1><loc_x2><loc_y2> with coordinates scaled to the 0–999 range the model expects. That's the trick worth knowing: you can feed that string back into the Florence2 node's text_input for region-aware tasks, or just use it as an understandable summary of where the object sits.

Two inputs, both obvious:

  • F_BBOXES - straight from the Florence2 node's output.
  • index - which detection to pull. 0 is the first one the model reported.

The seven outputs are the payoff, and you'll use maybe four of them:

  • mask (MASK) - the binary mask for that one object. Wire it into masking, inpainting, or a mask-to-image node for background-removal-style jobs.
  • label (STRING) - the model's name for the object ("person", "dog"...).
  • loc_string (STRING) - the Florence-2 location token string, ready to feed back as text_input.
  • width, height, x, y (INT) - the box's size and top-left corner in pixels. Handy for feeding a crop node or for drawing it yourself.

Worth knowing if you're automating: this pack is deprecated - the README says to use Kijai's ComfyUI-Florence2 - and this node still works fine for single-image jobs. The model files are shared, so nothing re-downloads if you switch.

Troubleshooting, grounded in the actual code: if index is out of range, you don't get an error - you get an empty (all-black) mask and an empty label. That's easy to mistake for a broken model when it's just a bad index. Also, "OCR with region" returns 8-point quad boxes, not 4-point rectangles; the node silently converts those to their axis-aligned bounding box, which is usually what you want for a mask anyway. If F_BBOXES ever arrives as a string (a downstream error state), the node returns a blank 512×512 mask rather than crashing - a friendly fail, but one you'll want to catch upstream.

Install via ComfyUI Manager (search "ComfyUI-Florence-2") or git clone https://github.com/spacepxl/ComfyUI-Florence-2 into custom_nodes/. It ships no requirements.txt, so if the pack loads at all, the hard deps (transformers, matplotlib) are already handled by whoever installed the main Florence2 node. In short: pick an index, take the mask, feed the location string back if you want a second pass. That's the whole game.

CategoryFlorence2

Inputs (2)

NameTypeDefaultDescription
F_BBOXESF_BBOXES
indexINT0

Outputs (7)

NameTypeDescription
maskMASK
labelSTRING
loc_stringSTRING
widthINT
heightINT
xINT
yINT