Nodes/ComfyUI-ArchiGraph/To Nparray πŸ¦β€πŸ”₯
ComfyUI Node

To Nparray πŸ¦β€πŸ”₯

The bridge in β€” feed ComfyUI images to the OpenCV half of the graph

By vincentfsΒ·Created 2 years agoΒ·Updated 9 months agoΒ· 3
To Nparray πŸ¦β€πŸ”₯
  • images
  • masks
  • nparrays

This is where every ArchiGraph workflow starts. Standard ComfyUI images live as float 0–1 RGB torch tensors; OpenCV - and every node in this pack that wraps it - wants 8-bit 0–255 BGR numpy arrays. To Nparray performs that conversion, taking a normal IMAGE and handing you the NPARRAY that every OpenCV node downstream is waiting for.

Why you'd reach for it

You reach for it the moment you want to do real computer vision on an image inside ComfyUI - edge detection, contours, thresholding, anything in the pack's OpenCV category. It's the mandatory entry gate: feed To Nparray from a Load Image or a VAE-decoded frame, and suddenly Sobel, Threshold, Canny, Hough, and the rest all light up. The pack's whole architecture-crunching pitch (floor plans, line extraction, connected components) assumes you crossed this bridge first. It also doubles as a mask-to-array converter, which is where the second input comes in.

How it works

The conversion is the mirror image of AG To Image. For an IMAGE, it takes the float 0–1 RGB tensor, clips it, scales by 255, casts to uint8, and reverses the channel order to BGR - because OpenCV's native layout is BGR and its functions will quietly give you wrong results if you feed them RGB. Masks get their own path: a mask tensor (B, H, W) becomes a uint8 single-channel array with an added trailing dimension, (B, H, W, 1), scaled to 0–255.

The inputs and output

Unusually for a node, both inputs are optional:

  • images - an IMAGE to convert.
  • masks - an optional MASK. The tooltip states the rule plainly: if provided, it overwrites the images input. Wire both and only the mask comes through.

The output is nparrays, a single NPARRAY. Feed nothing at all and you get a 1Γ—1Γ—1Γ—1 dummy uint8 array - which is a silent-footgun kind of behavior, so don't leave both inputs unplugged and expect an error to tell you.

Installing it

Part of ComfyUI-ArchiGraph - ComfyUI Manager β†’ search "ArchiGraph" β†’ install β†’ restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/vincentfs/ComfyUI-ArchiGraph
cd ComfyUI-ArchiGraph
pip install -r requirements.txt   # or install.bat / install.sh

The OpenCV requirements (opencv-python, opencv-contrib-python) are what make this node's output usable by the pack's processing nodes.

Where people get burned

The thing that trips up everyone new to this pack is the silent change in your mental model. You were in float 0–1 RGB land; you're now in integer 0–255 BGR land. Arithmetic behaves differently, previews need different handling, and if you wire the output back into a normal node expecting IMAGE, it won't connect - that's the NPARRAY type being pack-internal, and it's exactly what AG To Image is for on the way out.

The mask-overrides-image rule is the other surprise, because it's easy to wire both inputs without realizing the mask silently won. And if your colors look swapped somewhere downstream, retrace the channel flips: To Nparray makes things BGR, To Image assumes BGR on the way back, so a clean round trip is fine - but mixing in an array from anywhere else breaks the assumption.

CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ“€ OpenCV

Inputs (2)

NameTypeDefaultDescription
imagesoptIMAGEβ€”
masksoptMASKOptional mask to convert to Nparray. If provided, will overwrite the images input.

Outputs (1)

NameTypeDescription
nparraysNPARRAYβ€”