Views
No views yet
depth-anything/Depth-Anything-V2-Small-hf for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.DepthAnythingV2DepthEstimation, relative).1import os
2os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
3
4from PIL import Image
5from zeromodels.models.depth_anything_v2 import DepthAnythingV2DepthEstimation, DepthAnythingV2ImageProcessor
6
7model = DepthAnythingV2DepthEstimation.from_weights("zeromodels/depth_anything_v2_small")
8processor = DepthAnythingV2ImageProcessor.from_weights("zeromodels/depth_anything_v2_small")
9
10image = Image.open("your_image.jpg").convert("RGB")
11output = model(processor(image)["pixel_values"], training=False)
12depth = processor.post_process_depth_estimation(
13 output, original_size=(image.height, image.width)
14)
15print(depth.shape)from_weights("zeromodels/<variant>"):| Variant | Hub | Output |
|---|---|---|
depth_anything_v2_small | zeromodels/depth_anything_v2_small | relative |
depth_anything_v2_base | zeromodels/depth_anything_v2_base | relative |
depth_anything_v2_large | zeromodels/depth_anything_v2_large | relative |
depth_anything_v2_metric_indoor_small | zeromodels/depth_anything_v2_metric_indoor_small | metric indoor |
depth_anything_v2_metric_indoor_base | zeromodels/depth_anything_v2_metric_indoor_base | metric indoor |
depth_anything_v2_metric_indoor_large | zeromodels/depth_anything_v2_metric_indoor_large | metric indoor |
depth_anything_v2_metric_outdoor_small | zeromodels/depth_anything_v2_metric_outdoor_small | metric outdoor |
depth_anything_v2_metric_outdoor_base | zeromodels/depth_anything_v2_metric_outdoor_base | metric outdoor |
depth_anything_v2_metric_outdoor_large | zeromodels/depth_anything_v2_metric_outdoor_large | metric outdoor |
KERAS_BACKEND before importing Keras / zeromodels.DepthAnythingV2DepthEstimation.from_weights("hf:depth-anything/Depth-Anything-V2-Small-hf").