Depth-Anything-V2#
This example demonstrates using the Depth-Anything-V2 tool for depth estimation on images.
from vision_agent_tools.models.depth_anything_v2 import DepthAnythingV2
# (replace this path with your own!)
test_image = "path/to/your/image.jpg"
# Load the image
image = Image.open(test_image)
# Initialize the depth map estimation model.
depth_estimate = DepthAnythingV2()
# Run the inference
results = depth_estimate(image)
# Let's print the obtained depth map
print(results.map)
DepthAnythingV2
#
Bases: BaseMLModel
Model for depth estimation using the Depth-Anything-V2 model from the paper Depth Anything V2.
__call__(image, grayscale=False)
#
Depth-Anything-V2 is a highly practical solution for robust monocular depth estimation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Union[str, Image, ndarray]
|
The input image for depth estimation. Can be a file path, a PIL Image, or a NumPy array. |
required |
grayscale |
bool
|
Whether to return the depth map as a grayscale image. If True, the depth map will be normalized to the range [0, 255] and converted to uint8. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
DepthMap |
DepthMap
|
An object type containing a numpy array with the HxW depth map of the image. |
__init__()
#
Initializes the Depth-Anything-V2 model.
DepthMap
#
Bases: BaseModel
Represents the depth map of an image.
Attributes:
Name | Type | Description |
---|---|---|
map |
Any
|
HxW raw depth map of the image. |