Nodes/ComfyUI CV/CV Numbers To Array
ComfyUI Node

CV Numbers To Array

Get a list of floats back into numpy

By bmad4ever·Created 3 months ago·Updated 14 days ago· 1
CV Numbers To Array
    • nparray
    • count
    ◄values—►
    ◄columns0►
    ◄dtypefloat32►

    ComfyUI has two ways to carry a sequence of numbers: a proper list (what helper packs and foreach bodies produce) and an NPARRAY (what every geometry node in this pack consumes). This node is the return trip - a list of FLOATs becomes one array, reshaped into rows on the way in.

    It's the counterpart of CV Array To Numbers, and the pair exist because the interesting work often happens outside the array world. A Math Expression node, a sorted list, an Inspire foreach body: all of those speak list, and eventually you want a point set or a matrix back.

    How it works

    values is a ComfyUI list of floats - and the node is declared as an input-list node, which is ComfyUI's way of saying "this socket expects the list as a whole, not one item per invocation." Practically: wire it from anything that emits a variable-length list. A single value yields a one-element array, so you can't accidentally get zero.

    columns is the reshape, and it's the entire ergonomics of the node. 0 keeps the result 1-D. 2 gives you an (N,2) point set - wire that into anything that draws points. 3 gives an (N,3) cloud for the 3-D side. The value count has to divide by columns, and if it doesn't you get a raise, which is the correct call: a ragged reshape is a bug in your graph and there's no meaningful fallback.

    dtype picks the element type: float32 (default, what cv2's geometry functions want), float64, int32 (indices, labels), uint8.

    Outputs: nparray plus count - the number of rows, so with columns=2 on 40 values you get count = 20. That trips people up once.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_cv
    

    Manager → ComfyUI CV. Restart, reload the tab. Python ≥ 3.12, V3-API ComfyUI, and the pack's one real dependency, opencv-contrib-python-headless~=5.0.0.93. This node itself is pure numpy.

    When you'd actually use it

    Three cases worth naming, because "convert a list" sounds like nothing:

    • Round-tripping a measured quantity. CV Array To Numbers out of a distances array, a sort or a filter in whatever node does that well, then back in here - the transform stays in the array world and the sorting doesn't.
    • Building a point set by hand. CV Points Literal covers the common case, but a computed list (interpolating between two ends, for instance) needs this node to become (N,2).
    • Bridging helper packs. The README lists ComfyUI-Inspire-Pack, ComfyUI-Custom-Scripts and Basic Data Handling as dependencies of some of the pack's example workflows, and this is the node that makes that dependency useful rather than decorative.

    Common issues

    "N value(s) do not divide into rows of 3". Your list length doesn't match columns. That's the error text, and it's honest about it - pad, truncate, or change columns.

    count isn't what you expected. It counts rows, not values.

    A widget feeding an input-list socket with surprising results. This node forces values to be an input rather than a widget, which is right - but it means you must have something that emits a list. A plain FLOAT primitive gives you a 1-element array, which is valid and probably not what you wanted.

    dtype drift. The internal accumulation is float64 and the result is cast at the end, so choosing int32 truncates. For values that are already integrals (indices, counts) that's fine; for anything measured, keep float32.

    Categoryimage/CV/low-level

    Inputs (3)

    NameTypeDefaultDescription
    valuesFLOATA ComfyUI list of FLOATs (any node that emits a list, e.g. 'CV Array To Numbers', 'Basic data handling: convert LIST to Data List', an Inspire foreach body). A single value yields a 1-element array.
    columnsINT00–4096Row width. 0 keeps the result 1-D; 2 makes an (N,2) point set, 3 an (N,3) cloud. The value count must divide by it.
    dtypeCOMBOfloat32Element type of the result. float32 is what most cv2 geometry functions want; int32 for indices/labels.

    Outputs (2)

    NameTypeDescription
    nparrayNPARRAYThe collected array, (N,) or (N, columns).
    countINTNumber of rows in the result.