Nodes/ComfyUI-DepthAnythingAccel/Estimate Depth (PyTorch)
ComfyUI Node

Estimate Depth (PyTorch)

The honest baseline, and the node that enforces a 2.6MP budget

By PineCookie·Created a day ago·Updated a day ago· 0
Estimate Depth (PyTorch)
  • model
  • image
  • depth

This is the unaccelerated pass: your image goes in, a depth map comes out, and it runs entirely on PyTorch. If you only ever install one node from this pack, it's this one plus the PyTorch loader. And it's the pass you should keep around even after you've gone ONNX, because it's the thing you compare against when an accelerated backend starts producing something slightly off.

What it actually does

Feed it an IMAGE. The image is not squashed to 518×518 the way a lot of depth preprocessors do. It's aligned down to the nearest multiple of 14 - the ViT patch grid - resized to that with a bilinear filter only if it has to move at all, then normalized with the standard ImageNet mean and std. A 1024×768 photo becomes 1022×756. A 512×512 image becomes 504×504, which is the kind of detail that explains why your output is one patch-fraction softer than the input.

Then the raw depth comes back, gets min-max normalized per image in the batch so the nearest pixel is white and the farthest is black, is bilinear-resized back up to your original resolution, and is expanded to three identical channels so it drops straight into ComfyUI's IMAGE type. Yes, that's wasteful - it's a grayscale map wearing an RGB costume - but it means you can wire it to Save Image, a ControlNet, or a parallax node without a conversion step.

Because it's relative depth (nearer versus farther, not metres), it's exactly what depth ControlNet wants. If you need actual distances you're on the wrong model family entirely.

The inputs that matter

Just two, and neither is a knob:

  • model - the DEPTHACCEL_MODEL handle from Load Depth Model (PyTorch).
  • image - the IMAGE to estimate on.

The output is a single depth IMAGE. Wire it into ControlNetApplyAdvanced alongside a depth ControlNet (start around weight 0.8 for strict layout matching, 0.4–0.7 if you want the composition to breathe), into an image saver, or into a warping node for the parallax trick. Nothing else in the node is configurable - precision and the checkpoint were already decided at load time.

The part that bites: resolution budgets

Native resolution is the selling point and also the cost. Before it runs, the node checks the patch-aligned pixel count against a per-precision budget and refuses work it thinks will blow up your VRAM: roughly 2.6 megapixels for FP32 (which is why 1536×1536 works and a 4K still doesn't) and 4.7 MP for FP16/BF16, comfortably above the 2016×2016 profile the accelerated backends advertise.

Exceed it and you get a ValueError naming your aligned resolution, the budget, and your options - resize the image, or move to an FP16 ONNX/TensorRT backend for higher native resolutions. That's a deliberate fail-fast rather than a CUDA out-of-memory. The budget itself came from a real finding: FP32 vitl OOMs around 3.5MP on a 16GB card.

Related, from the community rather than this pack: the Giant model is the quality ceiling and the memory hog. At 1024×1024 on 24GB it's fine; beyond that, expect to be turned away.

Speed, honestly

Measured on an RTX 5070 Ti at 784×1176 in FP16, PyTorch is the slow tier - 29.1 ms for Small, 51.0 ms for Base, 127.3 ms for Large - against 20.5 / 37.4 / 93.5 ms for fused ONNX and 7.5 / 16.5 / 47.3 ms for TensorRT. On a single still image, none of that matters; you will not notice 127 ms. It matters when you're running a batch, or a video frame by frame, where the same numbers compound into minutes. That's the whole reason the rest of this pack exists - but the PyTorch path is the correctness reference all three backends are verified against (correlation ≈ 1.0 against FP32, normalized error ≈ 1e-3), so it isn't the "bad" option, just the slow one.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/PineCookie/ComfyUI-DepthAnythingAccel
cd ComfyUI-DepthAnythingAccel
python -m pip install safetensors huggingface-hub onnxruntime-gpu

ComfyUI Manager does the same if you search DepthAnythingAccel. Graph for it:

[Load Depth Model (PyTorch)] → [Estimate Depth (PyTorch)] → Save Image

If something's wrong

Checkpoint missing from the dropdown? Put the file in ComfyUI/models/depthanything/ and refresh - the pack registers that folder itself. Depth map looks flat or inverted relative to what you expected? That's usually an over-strong ControlNet weight talking, not the node; relative depth has no fixed direction of "correct" until the ControlNet interprets it. And if the node errors about the pixel budget, don't fight it with a --lowvram flag - the guard is already doing the job those flags usually don't.

CategoryDepthAnythingAccel/Reference

Inputs (2)

NameTypeDefaultDescription
modelDEPTHACCEL_MODEL
imageIMAGE

Outputs (1)

NameTypeDescription
depthIMAGE