Nodes/ComfyUI-Marigold-v2/Marigold V2 Save Raw (.npy)
ComfyUI Node

Marigold V2 Save Raw (.npy)

Getting the actual floats out of ComfyUI

By visualbruno·Created 29 days ago·Updated 21 days ago· 15
Marigold V2 Save Raw (.npy)
  • raw
    ◄filename_prefixmarigold_v2/prediction►

    What it's for

    Everything else in this pack hands you a picture. This one writes the numbers.

    It takes the raw output of Marigold V2 Predict and saves float32 .npy files into ComfyUI's output folder - [H, W] for depth, [3, H, W] for normals and albedo, in the model's own units, with no normalisation applied. That matches what the upstream repo's scripts/infer.py writes, which is the point: it's the handoff from "I made a depth map" to "something else consumes a depth map".

    You reach for it when the map is going somewhere that doesn't speak PNG. Blender displacement, a mesh or STL pipeline, dmap2gcode, a parallax pass, a Python script, whatever your own downstream code is. Those all want real values and a shape, and a colourised PNG gives them 8-bit precision and a colormap they have to invert. It's also the only sane way to compare two runs numerically, since the image output is per-image normalised and therefore not comparable across frames.

    What lands on disk

    Worth being precise, because "it saved something" isn't the same as "it saved what you think".

    Depth is a single [H, W] plane. Normals and albedo are [3, H, W]. Files are named from filename_prefix with the usual counter suffix, and one file is written per image in the batch.

    There's also a JSON sidecar next to the .npy files, and it's a genuinely useful detail: it records the modality, the checkpoint label, whether far_is_high is true for that checkpoint, and the list of files. That last one saves you from a real headache, because affine-invariant depth has no absolute scale - if you come back to a folder of .npy files a week later, the sidecar is how you know whether values grow or shrink with distance, and whether you're looking at Log-stage2 or Disparity-base. Read it before you assume anything about orientation.

    Nothing here normalises. Depth stays in the model's units with its unknown scale and shift per image. If you feed these straight into a down-stream tool expecting 0–1, do the min-max yourself, and do it per image.

    The inputs

    raw - the MARIGOLDV2_RAW from Predict. Depth, normals, or albedo, all fine.

    filename_prefix - default marigold_v2/prediction. Because it goes through ComfyUI's standard save-path machinery, a slash in it becomes a subfolder under output/, so the default drops your files in ComfyUI/output/marigold_v2/. Change the prefix per experiment unless you enjoy twelve folders all called prediction.

    And no outputs, which is normal: it's an output node. ComfyUI's execution model works backwards from output nodes and treats them as always-run, which is why a Preview Image always fires and a randomiser in the middle of your graph doesn't. This node behaves the same way - it's a terminal node, so wire it and stop.

    Install

    ComfyUI Manager, search ComfyUI-Marigold-v2, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/visualbruno/ComfyUI-Marigold-v2
    ../../python_embeded/python.exe -m pip install -r ComfyUI-Marigold-v2/requirements.txt
    

    No extra dependency for this one - NumPy is already there, and the pack's requirements.txt (diffusers, peft, bitsandbytes, transformers, accelerate, safetensors, huggingface_hub, matplotlib) is the same install for all five nodes.

    Reading the files back

    The shapes are the only thing that trips people up. Depth comes out [H, W], so np.load(...) gives you a 2D array and you can hand it straight to a height-field consumer; normals come out [3, H, W] - channels-first, because that's what the model produced - so anything expecting [H, W, 3] needs a transpose in between:

    import json, numpy as np
    
    depth = np.load("output/marigold_v2/prediction_00001_.npy")   # [H, W], model units
    normals = np.load("output/marigold_v2/prediction_00002_.npy") # [3, H, W]
    rgb = np.transpose(normals, (1, 2, 0))                        # [H, W, 3]
    
    meta = json.load(open("output/marigold_v2/prediction_00001_.json"))
    print(meta["modality"], meta["checkpoint"], meta["far_is_high"])
    

    One practical note: depth from this node is what you'd build a printable bas-relief or a displacement mesh from, which has always been Marigold's cleanest standout job - the whole reason the ETH team's original demo got the reaction it did. Save the raw, do your own normalisation and smoothing, and export from there. Colourised previews are for looking at; these files are for building.

    CategoryMarigold V2

    Inputs (2)

    NameTypeDefaultDescription
    rawMARIGOLDV2_RAW—
    filename_prefixSTRINGmarigold_v2/prediction—

    Outputs (0)

    No outputs