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, revision 256875362cff76724b920335dfb4b29dd611f66e.

Model file

Video-Depth-Anything-Small-fp32.tflite · FP32 · 116.28 MB. The file hash is in 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. The example below processes the first 32 frames and saves depth for their square crops.

Run on CPU

pip install ai-edge-litert huggingface_hub numpy opencv-python-headless
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 and paper. 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.

Citation

@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}
}
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for litert-community/Video-Depth-Anything-Small

Finetuned
(3)
this model

Paper for litert-community/Video-Depth-Anything-Small