ComfyUI Node

Adapt_Coordinates

Rescale bounding-box coordinates from a 512 base

By 438443467·Created 2 years ago·Updated about a year ago· 27
Adapt_Coordinates
    • coord_str
    coordinates
    width
    height

    Coordinate remapping is one of those fiddly things that eats an afternoon, and this node exists to do one specific version of it: take a list of x/y points that were generated at a 512×512 canvas and rescale them to a different width and height. If you've ever had a detector or a mask workflow hand you coordinates in one resolution while your actual image lives at another, you know exactly why this exists.

    How it works

    You feed it a coordinates string in the shape of a Python list of dicts - [{"x":10,"y":20},{"x":30,"y":40}] - plus the target width and height. It computes scale factors as round(width / 512) and round(height / 512), then multiplies each coordinate by the matching factor. Coordinates that are already 0 stay 0. The result comes back as the same list-of-dicts format in a coord_str string, ready to feed back into whatever consumed the original.

    A concrete example: coordinates from a 512×512 run, target 1024×1024 → both scale factors are 2, so {"x":100,"y":50} becomes {"x":200,"y":100}.

    Inputs and outputs

    • coordinates - STRING, the [{"x":…,"y":…}, …] list. It's forceInput, so it's meant to be wired from another node's output rather than typed.
    • width, height - INT, the target dimensions (also forceInput).

    Output: coord_str - STRING, the rescaled coordinate list.

    The part that should make you pause

    The node evaluates your coordinates string with Python's eval(). That's fine when the string comes from a trusted workflow node, and a real problem if it ever comes from anything user-controlled - eval on untrusted text is arbitrary code execution, full stop. Keep this node fed only by your own workflow constants. Also note the 512 baseline is hardcoded and the scale factor is rounded, not computed exactly - for a 512-based pipeline that's fine, but feeding it coordinates from a 1024-based detector and expecting precision will give you sloppy boxes. And, standard for the pack: this node was removed in the April 2025 rewrite, so a fresh install only ships the captioner; the code lives in the old Load_Image_Batch.py in git history.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/438443467/ComfyUI-GPT4V-Image-Captioner
    

    Restart ComfyUI. No models, no dependencies. If you need general coordinate math with proper floating-point scaling and no eval, a dedicated geometry node pack is the safer route - this one is for quick 512-based remaps only.

    CategorySanmi Simple Nodes/Simple NODE

    Inputs (3)

    NameTypeDefaultDescription
    coordinatesSTRING
    widthINT
    heightINT

    Outputs (1)

    NameTypeDescription
    coord_strSTRING