Nodes/ComfyUI-TBG-SAM3/TBG SAM3 Depth Map
ComfyUI Node

TBG SAM3 Depth Map

A depth map node that's honest about being the simple option

By Ltamann·Created 10 months ago·Updated about a month ago· 169
TBG SAM3 Depth Map
  • image
  • segs
  • depth_image
  • depth_mask
modefull_image
normalizetrue

Here's the thing to know up front: TBG SAM3 Depth Map has nothing to do with SAM3. It's a convenience node the pack author threw in - a MiDaS-based depth estimator that sits alongside the segmentation nodes. The README says it outright: "simple implementation, and there are more advanced depth map methods available." It's not hiding anything, which is refreshing, because a lot of packs would slap a fancy name on this and call it done.

What it actually is

Under the hood it loads Intel/dpt-hybrid-midas through Hugging Face Transformers - the same MiDaS family that's been the SD ecosystem's depth baseline since SD 2.0. MiDaS produces relative depth maps (which parts of the scene are closer than others), not metric distances, and for most ComfyUI use that's all you need anyway. It estimates depth for whatever image you feed it and returns both a grayscale depth image and a raw depth mask.

Where it earns its place in this pack: per_segment mode. In full_image mode it's a plain depth estimator - fine, but nothing special. In per_segment mode you hand it the SEGS from the segmentation node and it estimates depth for each segment individually, masked, then merges them. That's a genuinely different output from a whole-image depth map: you get depth per detected object, which is the sort of thing you'd feed into per-object refinement, relighting, or geometry work. That's why it's in the pack at all.

The inputs and output

  • image - the image to estimate depth for (accepts a batch too).
  • mode - full_image (default) or per_segment. Per-segment requires the optional segs input; the node's own description warns you, and the code raises a clear error if you skip it.
  • normalize - defaults to on, scaling the raw depth values to 0–1 so the map is readable as an image. Turn it off if you want raw relative values.
  • segs (optional) - the SEGS output from TBG SAM3 Segmentation, only used in per-segment mode.

Outputs are depth_image (a 3-channel grayscale IMAGE, white = close, black = far) and depth_mask (a single-channel MASK, same values). The mask is the one to wire into anything that wants a mask or tensor; the image is for previews and for piping into image-space processing.

Installing

Pack install is the usual: ComfyUI Manager (search "TBG-SAM3") or clone into custom_nodes and pip install -r requirements.txt. The depth node itself doesn't need the SAM3 checkpoint - but it does download dpt-hybrid-midas from Hugging Face the first time it runs. That's a separate download from the SAM3 model, so don't panic when the console shows a second model being pulled.

Where people get burned

  • Silent zero output. If the depth model fails to load, the code falls back to returning a dummy all-zeros depth map rather than erroring. You'll see the [SAM3] Could not load depth model message in the console - if your depth output is flat black, check there.
  • Expecting Depth Anything quality. This is a MiDaS hybrid, not Depth Anything v2. For a dedicated ControlNet depth preprocessor, the modern default is Depth Anything via comfyui_controlnet_aux, and you should reach for that if depth is the main event. This node is for when you're already in a TBG-SAM3 workflow and want a quick depth map without adding another pack.
  • Per-segment without SEGS. The mode is tempting and the error is clear, but you must feed segs or it throws.

It's the least flashy node in the pack and the author knows it. But as an inline convenience - depth per segment, right where you're already segmenting - it beats bolting on a second depth ecosystem just to get a mask.

CategorySAM3

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
modeCOMBOfull_image2 options: full_image, per_segment
normalizeBOOLEANtrue
segsoptSEGS

Outputs (2)

NameTypeDescription
depth_imageIMAGE
depth_maskMASK