Depth Anything¶
Documentation¶
- Class name:
DepthAnythingPreprocessor
- Category:
ControlNet Preprocessors/Normal and Depth Estimators
- Output node:
False
The DepthAnythingPreprocessor node is designed to preprocess images for depth estimation tasks by utilizing different pretrained models based on the checkpoint name provided. It abstracts the complexity of model selection and preprocessing steps, offering a streamlined way to generate depth maps from input images.
Input types¶
Required¶
image
- The input image to be processed for depth estimation. This image is transformed and fed into the selected model to generate a depth map.
- Comfy dtype:
IMAGE
- Python dtype:
torch.Tensor
Optional¶
ckpt_name
- Specifies the pretrained model checkpoint to use for depth estimation. The choice of checkpoint affects the model's performance and accuracy.
- Comfy dtype:
COMBO[STRING]
- Python dtype:
str
resolution
- The resolution to which the input image is resized before processing. This parameter can influence the detail level of the resulting depth map.
- Comfy dtype:
INT
- Python dtype:
int
Output types¶
image
- Comfy dtype:
IMAGE
- The output is a depth map of the input image, providing a pixel-wise estimation of depth.
- Python dtype:
torch.Tensor
- Comfy dtype:
Usage tips¶
- Infra type:
GPU
- Common nodes:
Source code¶
class Depth_Anything_Preprocessor:
@classmethod
def INPUT_TYPES(s):
return create_node_input_types(
ckpt_name=(["depth_anything_vitl14.pth", "depth_anything_vitb14.pth", "depth_anything_vits14.pth"], {"default": "depth_anything_vitl14.pth"})
)
RETURN_TYPES = ("IMAGE",)
FUNCTION = "execute"
CATEGORY = "ControlNet Preprocessors/Normal and Depth Estimators"
def execute(self, image, ckpt_name, resolution=512, **kwargs):
from controlnet_aux.depth_anything import DepthAnythingDetector
model = DepthAnythingDetector.from_pretrained(filename=ckpt_name).to(model_management.get_torch_device())
out = common_annotator_call(model, image, resolution=resolution)
del model
return (out, )