Nodes/ComfyUI-Inference-Core-Nodes/[Inference.Core] MiDaS Depth Map
ComfyUI Node

[Inference.Core] MiDaS Depth Map

The original ControlNet depth model, still around for a reason

By LykosAI·Created 2 years ago·Updated about a year ago· 33
[Inference.Core] MiDaS Depth Map
  • image
  • IMAGE
a6.28
bg_threshold0.10
resolution512

MiDaS is the depth model that was already old news by the time most people discovered ControlNet - it shipped with SD 2.0's depth2img back in 2022 and was the default depth preprocessor for most of the SD 1.5 era. Depth Anything has since taken over as the general-purpose default, and rightly so: it generalizes better to weird images. But MiDaS earned its staying power the honest way, with sharp edges. A well-known community A/B test between MiDaS and the (theoretically more accurate) ZoeDepth landed on MiDaS specifically because its depth maps have crisper, more usable edges for ControlNet conditioning - precise geometric accuracy matters less here than a depth map that's easy for the model to follow.

How it works

MiDaS is a discriminative monocular depth model - trained directly to predict relative depth from a single image, no diffusion involved. It comes in a spread of sizes (DPT-Large down to MiDaS v2.1 Small) trading speed for cleaner gradients, though this node exposes the pipeline rather than a checkpoint picker. The two numeric parameters below are MiDaS-specific knobs inherited from its original implementation, used when the model also derives normal-style shading from the depth estimate - leave them at their defaults unless you're deliberately chasing a specific look.

The inputs and outputs that matter

  • image - required, your source image.
  • a (default ≈6.28, i.e. 2π) - an angle parameter used internally by MiDaS's depth-to-shading math. Default is the standard value; most people never touch it.
  • bg_threshold (default 0.1) - how aggressively background is clipped toward black. Raise it if distant background is bleeding detail into your depth map where you'd rather it stayed flat.
  • resolution (default 512) - working resolution.

One output: IMAGE, the grayscale depth map - feed it to a depth ControlNet.

How to install it

ComfyUI Manager: search ComfyUI-Inference-Core-Nodes, install, restart. By hand:

cd ComfyUI/custom_nodes
git clone https://github.com/LykosAI/ComfyUI-Inference-Core-Nodes

then run install.py, or pip install -e .[cuda12] (or .[cuda] / .[rocm] / .[directml] / .[cpu]). Restart ComfyUI. The MiDaS model weights download from Hugging Face the first time you run the node.

Common issues & troubleshooting

If your depth map looks murky or the background is a flat undifferentiated wash, try nudging bg_threshold down - a lower value preserves more subtle background depth variation instead of clipping it away. If it's the opposite problem - the background is noisy and pulling focus in your ControlNet result - raise it.

Beyond that, the honest limitation is just that MiDaS is an older model: on unusual scenes, reflective or transparent surfaces, and cluttered compositions, it tends to produce softer, less confident depth maps than Depth Anything. If your MiDaS output looks vague on a tricky image, that's not a setup problem - it's the model's ceiling. This pack ships Depth Anything as a separate node for exactly that situation; reach for it when MiDaS isn't cutting it rather than fighting the two parameters here.

CategoryControlNet Preprocessors/Normal and Depth Estimators

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
aoptFLOAT6.280–15.70796326794897
bg_thresholdoptFLOAT0.100–1
resolutionoptINT51264–2048

Outputs (1)

NameTypeDescription
IMAGEIMAGE