Instructions to use zeromodels/depth_anything_v2_base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/depth_anything_v2_base with ZeroModels:
# pip install -U zeromodels # ZeroModels is pure Keras 3, so pick a backend: "jax", "torch" or "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" from zeromodels import AutoZModel # AutoZModel reads the repo's model_type and loads the matching class. # For a task head use the matching loader, e.g. AutoZMImageClassify / AutoZMDetect / # AutoZMSemanticSegment / AutoZMTextGenerate (see zeromodels.auto). model = AutoZModel.from_weights("zeromodels/depth_anything_v2_base") - Keras
How to use zeromodels/depth_anything_v2_base with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://zeromodels/depth_anything_v2_base") - DepthAnythingV2
How to use zeromodels/depth_anything_v2_base with DepthAnythingV2:
# Install from https://github.com/DepthAnything/Depth-Anything-V2 # Load the model and infer depth from an image import cv2 import torch from huggingface_hub import hf_hub_download from depth_anything_v2.dpt import DepthAnythingV2 # instantiate the model model = DepthAnythingV2(encoder="<ENCODER>", features=<NUMBER_OF_FEATURES>, out_channels=<OUT_CHANNELS>) # load the weights filepath = hf_hub_download(repo_id="zeromodels/depth_anything_v2_base", filename="depth_anything_v2_<ENCODER>.pth", repo_type="model") state_dict = torch.load(filepath, map_location="cpu") model.load_state_dict(state_dict) model.eval() raw_img = cv2.imread("your/image/path") depth = model.infer_image(raw_img) # HxW raw depth map in numpy - Notebooks
- Google Colab
- Kaggle
Download model.weights.h5 from zeromodels/depth_anything_v2_base: direct link, hf CLI and curl.
- Browser
- Download file 389 MB
-
https://huggingface.co/zeromodels/depth_anything_v2_base/resolve/main/model.weights.h5
- Command line
-
hf download hf://zeromodels/depth_anything_v2_base/model.weights.h5
-
curl -L -o model.weights.h5 https://huggingface.co/zeromodels/depth_anything_v2_base/resolve/main/model.weights.h5
389 MB
- Xet hash:
- b69f8263335bd5968e29d4e7f12caad585b59511b6974fb13c18e4e23443e183
- Size of remote file:
- 389 MB
- SHA256:
- 8aacc4a8550ccabaabce7e8df3471d11b31aadc92157ba85487a29bac9eb60cd
·
Xet efficiently stores Large Files inside Git, intelligently splitting files into unique chunks and accelerating uploads and downloads. More info.