Instructions to use zeromodels/depth_anything_v2_large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/depth_anything_v2_large 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_large") - Keras
How to use zeromodels/depth_anything_v2_large 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_large") - DepthAnythingV2
How to use zeromodels/depth_anything_v2_large 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_large", 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
Commit History
-
Fix Collection badge link to the current zeromodels collection slug
Verified signature522a9b4 -
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
Verified signature3ea31d2
-
Upgrade kf_config.json to v2 (nested config + weight_dtype)
Verified signaturea4f0fd9 -
Upgrade kf_config.json to v2 (nested config + dtype)
Verified signature40acd42
-
docs: load image processor via from_weights
Verified signature6f8773e -
fix readme.md
Verified signature829383c -
fix readme.md
Verified signature1e05a12 -
fix readme.md
Verified signaturef5ee371
-
Upload kf_preprocessor.json with huggingface_hub
Verified signature2bdc082 -
Upload kf_config.json with huggingface_hub
Verified signature5944ae5 -
Upload README.md with huggingface_hub
Verified signature5d9919c -
Upload README.md with huggingface_hub
Verified signature67fddee
-
Upload folder using huggingface_hub
Verified signaturee44015b -
initial commit
Verified signature1df6f41