Nodes/ComfyUI-DeepStereo/DeepStereo: MiDaS Depth Estimator
ComfyUI Node

DeepStereo: MiDaS Depth Estimator

This node is why you can turn any photo into a Magic Eye without painting depth

By SanDiegoDude·Created about a year ago·Updated about a year ago· 3
DeepStereo: MiDaS Depth Estimator
  • image
  • depth_map
  • original_image
model_typeMiDaS_small
process_width0
invert_depthfalse
contrast1.0
brightness0.00
gamma1.0
depth_min0.00
depth_max1.00
blur_radius0
normalize_depthtrue

The headline feature of this pack is "AI-powered autostereograms," and this is the node that makes that true. The MiDaSDepthEstimator looks at a flat photo and writes a grayscale depth map - bright pixels near, dark pixels far - and that map is exactly the height-field an autostereogram needs. No hand-painting, no 3D scene, no depth sensor. One image in, a depth map out, and everything downstream in the DeepStereo pack runs off it.

It's built on Intel ISL's MiDaS, the model that shipped with SD 2.0's depth2img and was the default depth ControlNet preprocessor for years. Not the newest depth model in the world - Depth Anything V2 is the usual recommendation for ControlNet these days - but for feeding a stereogram, MiDaS's sharp edges are exactly what you want, and the pack integrates it natively.

How it works

Pick a model_type from three: MiDaS_small (default, fast, fine for previews), DPT_Hybrid (middle ground), and DPT_Large (best quality - the README's recommendation for final renders). On first use the node downloads the weights through torch.hub from the intel-isl/MiDaS repo and caches them in ComfyUI's models/controlnet/midas_models directory, so the first run needs internet and patience (the DPT models are a couple hundred megabytes). It runs on CUDA if you have it.

Under the hood it's more than a bare estimator. MiDaS outputs inverse depth, so the node flips it, normalizes it, and then exposes the processing knobs that matter for stereograms:

  • process_width - downscale to a processing width (rounded to multiples of 32) to speed up inference; 0 uses the original size.
  • contrast, brightness, gamma - tune the map's shape right at the source, no separate pass needed.
  • depth_min / depth_max - clip the depth range and renormalize; pull them inward to make the pop stronger.
  • invert_depth - flip near/far. Fixes the "everything looks punched into the screen" failure.
  • blur_radius - Gaussian smoothing for noisy maps.
  • normalize_depth (default on) - re-stretch the map to the full range after adjustments; turn it off if you want to keep a specific tonal envelope.

Two outputs: depth_map (the IMAGE you wire into StereogramGenerator or RandomDotStereogramGenerator) and original_image, a pass-through of what you fed in - handy when you want the source and its depth to travel together without an extra reroute.

Troubleshooting

The first-run download is the classic hangup. If the node errors on load, check that ComfyUI has internet access and that models/controlnet is writable - that's where it stashes weights. If your stereogram comes out flat, the map is probably low-contrast: raise contrast or squeeze depth_min/depth_max. If it pops the wrong direction, invert_depth.

Installing it

The node needs the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/SanDiegoDude/ComfyUI-DeepStereo
cd ComfyUI-DeepStereo
pip install -r requirements.txt

Restart ComfyUI, or install via ComfyUI Manager (search ComfyUI-DeepStereo). Note the README's own clone command has a placeholder yourusername/... URL - the real repo is the one above. And unlike the pack's utility nodes, this one does fetch weights on first run, so budget a download before your first workflow.

CategoryDeepStereo/Depth

Inputs (11)

NameTypeDefaultDescription
imageIMAGE
model_typeCOMBOMiDaS_small3 options: MiDaS_small, DPT_Large, DPT_Hybrid
process_widthoptINT00–2048Width for processing (0 = use original size)
invert_depthoptBOOLEANfalseInvert depth values
contrastoptFLOAT1.00.1–3Adjust depth map contrast
brightnessoptFLOAT0.00-1–1Adjust depth map brightness
gammaoptFLOAT1.00.1–3Gamma correction
depth_minoptFLOAT0.000–1Minimum depth value
depth_maxoptFLOAT1.000–1Maximum depth value
blur_radiusoptINT00–20Blur radius for smoothing
normalize_depthoptBOOLEANtrueNormalize depth to full range after adjustments

Outputs (2)

NameTypeDescription
depth_mapIMAGE
original_imageIMAGE