DepthAnything_V2

class grid.model.perception.depth.depth_anything_v2.DepthAnything_V2(*args, **kwargs)

DepthAnything_V2: Depth Estimation Model

This class implements a wrapper for the DepthAnything_V2 model, which estimates depth maps from RGB images. The model supports 'metric' and 'relative' modes, which load different pre-trained models based on the specified mode. We use the VIT Large encoder.

The model supports different encoder types, which are defined in MODEL_CONFIGS.

Credits:

https://huggingface.co/spaces/depth-anything/Depth-Anything-V2

License:

This code is licensed under the Apache 2.0 License.

__init__(mode='metric')

Initialize the DepthAnything_V2 model with the specified mode.

Loads the model weights based on the selected mode ('metric' or 'relative').

Parameters:

mode (str) -- The mode for depth estimation. Defaults to 'metric'.

Return type:

None

run(rgbimage)

Runs the DepthAnything_V2 depth estimation model on the given RGB image.

Parameters:

rgbimage (np.ndarray) -- The input RGB image.

Returns:

The depth map generated by the DepthAnything_V2 model.

Return type:

np.ndarray

Example

>>> img = np.random.randint(0, 255, (256, 256, 3)).astype(np.uint8)
>>> dam = DepthAnything_V2()
>>> depth = dam.run(img)
>>> print(depth.shape)
(256, 256)