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

Preview Nparray Image πŸ¦β€πŸ”₯

See what's actually in that nparray β€” without committing it to disk

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

    Once your image becomes a numpy array inside an ArchiGraph workflow, the standard preview nodes don't know what to do with it. This is the node that lets you peek. It takes a NPARRAY, converts it back to an image, and saves it to ComfyUI's temporary directory so it shows up in the preview panel - without cluttering your output folder with the twenty intermediate results you generated while tuning parameters.

    Why you'd reach for it

    Debugging OpenCV pipelines is miserable blind. If you've chained Sobel β†’ Threshold β†’ connected components and the output is garbage, you need to know which stage ate it. Drop Preview Nparray Image after each stage and you can actually see the edge map, the binary mask, the labeled blobs - whatever array is flowing through. It's the difference between guessing and looking.

    How it works

    This is a subclass of the pack's AG Save Nparray Image with the output location swapped. The parent converts the array to a standard image and hands it to ComfyUI's core SaveImage; this node overrides the constructor so instead of the output directory it targets folder_paths.get_temp_directory(), marks the result as "temp", and appends a random five-character suffix to every prefix so repeated runs don't collide with each other. It also drops the PNG compression level to 1, which trades file size for speed - appropriate for throwaway previews. Since it inherits the whole save pipeline, a batch of arrays is handled frame by frame and you get a preview per image.

    The inputs

    Just one: nparrays. That's the whole node. No filename, no quality slider, nothing to configure. An output node, so it returns nothing - it exists purely for its side effect.

    Installing it

    It's part of ComfyUI-ArchiGraph, so the install is the shared pack story: ComfyUI Manager β†’ search "ArchiGraph" β†’ install β†’ restart, or clone into custom_nodes and install the requirements:

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

    The pack needs opencv-python, opencv-contrib-python, matplotlib, and numba; no models to download, no keys.

    Where people get burned

    The classic miss is array scaling. This node's conversion expects an 8-bit image-like array in the 0–255 range. If you feed it a float array still sitting in 0–1 - which happens constantly right after AG To Nparray hands you floats - the preview renders as a nearly black box. Scale it first (* 255 and cast to uint8) or, easier, run the array through a node that normalizes it. The same AG To Image node does this conversion internally, so checking what it produces is a decent sanity test.

    Second, remember it's a preview. The files land in ComfyUI's temp directory and are treated as throwaway by design. If you decide you actually want to keep the result, switch to AG Save Nparray Image or save the equivalent IMAGE with a normal Save Image node. And if the preview ever looks blank, check that your array is at least 2D - a 1D array is technically savable but won't render as anything meaningful.

    CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ› οΈ Utils

    Inputs (1)

    NameTypeDefaultDescription
    nparraysNPARRAYβ€”

    Outputs (0)

    No outputs