Nodes/ComfyUI-YOLO/Convert to Dictionary
ComfyUI Node

Convert to Dictionary

Bounding boxes and masks, as a JSON dictionary

By kadirnar·Created 2 years ago·Updated 7 months ago· 121
Convert to Dictionary
  • bbox
  • mask
  • STRING

Debugging a detection workflow often ends with you squinting at tensors. This node serializes them instead. Feed it the optional bbox (the BOXES output from UltralyticsInference) and/or mask (the MASKS output), and it emits a JSON string: an objects array where each object carries a bbox with x, y, width, height, and - when a mask is supplied - a mask with its shape and full data.

Both inputs are optional. Give it just boxes and you get a clean list of object geometries; add masks and they get attached to the matching object. Give it neither and it returns a JSON that says "No input provided" rather than crashing - a nice touch in a pack that isn't always that careful.

One detail worth knowing if you're parsing the output downstream: the bbox values come through as floats, not rounded ints. A box edge at 100.5 stays 100.5, so don't write a parser that assumes clean integers.

It's an output node, so the JSON renders in its widget and is meant to be read by you or piped into something downstream. That makes it more of a bridge than a display: if you're driving a script, an API, or any text-based consumer from your detections, this is the node that hands over the data in a format that tool can actually parse. The mask data gets dumped in full, which can balloon on big images, but for a few boxes it's fine.

Install: ComfyUI Manager, search "ComfyUI-YOLO", or git clone https://github.com/kadirnar/ComfyUI-YOLO into custom_nodes, restart, and let Manager install ultralytics>=8.2.27. Nothing model-specific here - it never touches a detector; it just formats whatever tensors you route in.

CategoryUltralytics/Utils

Inputs (2)

NameTypeDefaultDescription
bboxoptBOXES
maskoptMASKS

Outputs (1)

NameTypeDescription
STRINGSTRING