Instructions to use litert-community/Video-Depth-Anything-Small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/Video-Depth-Anything-Small with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
|
Download README.md from litert-community/Video-Depth-Anything-Small: direct link, hf CLI and curl.
- Browser
- Download file 4.55 kB
-
https://huggingface.co/litert-community/Video-Depth-Anything-Small/resolve/main/README.md
- Command line
-
hf download hf://litert-community/Video-Depth-Anything-Small/README.md
-
curl -L -o README.md https://huggingface.co/litert-community/Video-Depth-Anything-Small/resolve/main/README.md
4.55 kB
| license: apache-2.0 | |
| library_name: litert | |
| pipeline_tag: depth-estimation | |
| base_model: depth-anything/Video-Depth-Anything-Small | |
| tags: | |
| - litert | |
| - tflite | |
| - fp32 | |
| - video-depth-estimation | |
| - video-depth-anything | |
| - relative-depth | |
| # Video-Depth-Anything-Small for LiteRT | |
| FP32 LiteRT/TFLite export of Video Depth Anything Small for temporally consistent relative-depth estimation. The ViT-S model processes one fixed **32-frame window** and retains the upstream temporal layers. It produces relative depth, not calibrated distances in metres. | |
| Source checkpoint: [depth-anything/Video-Depth-Anything-Small](https://huggingface.co/depth-anything/Video-Depth-Anything-Small), revision [`256875362cff76724b920335dfb4b29dd611f66e`](https://huggingface.co/depth-anything/Video-Depth-Anything-Small/tree/256875362cff76724b920335dfb4b29dd611f66e). | |
| ## Model file | |
| [Video-Depth-Anything-Small-fp32.tflite](Video-Depth-Anything-Small-fp32.tflite) · FP32 · 116.28 MB. The file hash is in [SHA256SUMS](SHA256SUMS). | |
| The TFLite signature is `main`. All input and output tensors are `float32`; shapes are fixed. Image/video decoding, preprocessing, and application postprocessing run on the host. | |
| | Direction | Name | Shape | Meaning | | |
| | --- | --- | --- | --- | | |
| | Input | `frames` | `[32, 3, 518, 518]` | 32 normalized RGB frames, TCHW; batch fixed to one clip | | |
| | Output | `relative_depth` | `[1, 32, 518, 518]` | Relative-depth maps, batch × time × height × width | | |
| ## Preprocessing and outputs | |
| Decode 32 consecutive RGB frames and apply a consistent center-square crop. Divide pixel values by 255, resize each crop to **518 × 518** with OpenCV cubic interpolation, and normalize with ImageNet mean `[0.485, 0.456, 0.406]` and standard deviation `[0.229, 0.224, 0.225]`. Stack in TCHW order; the public input has no batch dimension. For these square crops, the resize matches the upstream lower-bound transform with a multiple of 14. | |
| This file implements a single 32-frame window. For longer videos, host code must manage overlapping windows, temporal scale/shift alignment, and output resizing. See the [upstream inference implementation](https://github.com/DepthAnything/Video-Depth-Anything/blob/4f5ae23172ba60fd7bc11ef671cca678842c7072/video_depth_anything/video_depth.py). The example below processes the first 32 frames and saves depth for their square crops. | |
| ## Run on CPU | |
| ```bash | |
| pip install ai-edge-litert huggingface_hub numpy opencv-python-headless | |
| ``` | |
| ```python | |
| import numpy as np | |
| from huggingface_hub import hf_hub_download | |
| from ai_edge_litert.interpreter import Interpreter | |
| import cv2 | |
| cap = cv2.VideoCapture("video.mp4") | |
| frames = [] | |
| try: | |
| for _ in range(32): | |
| ok, bgr = cap.read() | |
| if not ok: | |
| raise ValueError("This example requires at least 32 frames") | |
| h, w = bgr.shape[:2] | |
| side = min(h, w) | |
| top, left = (h - side) // 2, (w - side) // 2 | |
| crop = bgr[top:top + side, left:left + side] | |
| rgb = cv2.cvtColor(crop, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0 | |
| rgb = cv2.resize(rgb, (518, 518), interpolation=cv2.INTER_CUBIC) | |
| rgb = (rgb - np.array([0.485, 0.456, 0.406])) / np.array([0.229, 0.224, 0.225]) | |
| frames.append(np.ascontiguousarray(rgb.transpose(2, 0, 1), dtype=np.float32)) | |
| finally: | |
| cap.release() | |
| frames = np.stack(frames) # [32, 3, 518, 518], no extra batch dimension | |
| model_path = hf_hub_download("litert-community/Video-Depth-Anything-Small", "Video-Depth-Anything-Small-fp32.tflite") | |
| interpreter = Interpreter(model_path=model_path, num_threads=4) | |
| interpreter.allocate_tensors() | |
| run = interpreter.get_signature_runner("main") | |
| depth = run(frames=frames)["relative_depth"][0] # [32, 518, 518] | |
| np.save("relative_depth.npy", depth) | |
| ``` | |
| ## Source and license | |
| Video Depth Anything is by Sili Chen and collaborators. See the [project](https://github.com/DepthAnything/Video-Depth-Anything) and [paper](https://arxiv.org/abs/2501.12375). The source implementation is pinned to revision `4f5ae23172ba60fd7bc11ef671cca678842c7072`. This repository contains the Apache-2.0 **Small** checkpoint. | |
| This FP32 conversion uses the original pretrained weights with a fixed-shape TFLite interface. License: [Apache 2.0](LICENSE). | |
| ## Citation | |
| ```bibtex | |
| @article{video_depth_anything, | |
| title={Video Depth Anything: Consistent Depth Estimation for Super-Long Videos}, | |
| author={Chen, Sili and Guo, Hengkai and Zhu, Shengnan and Zhang, Feihu and Huang, Zilong and Feng, Jiashi and Kang, Bingyi}, | |
| journal={arXiv:2501.12375}, | |
| year={2025} | |
| } | |
| ``` | |