dpt_dinov2_base_kitti

Monocular Depth Estimation

Generate a single-channel depth-map visualization from one RGB image with a DPT model backed by DINOv2 Base and trained for the KITTI domain

Apache-2.0
Depth Estimation
PyTorch
Transformers
English
by @AIOZAI
•
7
•
0

Last updated: 4 days ago


AIOZ AI Node Adapter Python

Monocular Depth Estimation

Generate a single-channel depth-map visualization from one RGB image with a DPT model backed by DINOv2 Base and trained for the KITTI domain.

Summary

Introduction

This repository exposes the model through the same AIOZ entry-point convention as other AI Node packages: construct an InputObject, call my_ai_lib.run(input_obj), and receive an OutputObject. The workflow accepts one local image path or HTTP(S) image URL, runs monocular depth estimation using facebook/dpt-dinov2-base-kitti, and returns a visualization PNG wrapped in an AIOZ FileObject.

The output is normalized independently for each image into the 8-bit range using disparity (inverse depth) representation, where foreground objects closer to the camera appear brighter and distant background elements appear darker.

Model details

ItemValue
TaskMonocular depth estimation
ArchitectureDPT (Dense Prediction Transformer)
BackboneDINOv2 Base (dinov2-base, ViT-B/14)
FrameworkPyTorch / Hugging Face Transformers (transformers>=4.35.0)
Checkpointmodels/depth_estimation
Training domainKITTI Vision Benchmark (autonomous driving)
Backbone resolution518 px (patch size: 14)

Parameters

Input

  • input_image (image/string, required): Local path or HTTP(S) URL for a JPEG, PNG, WebP, or BMP image.
  • device (string, optional): cpu, cuda, or gpu. The default is cuda; execution falls back to CPU when CUDA is unavailable.
  • model_storage_directory (string, optional): Parent directory containing depth_estimation. AIOZ supplies this value at runtime.

Output

  • output_image (image): A normalized disparity depth-map PNG named depth_map.png wrapped in an AIOZ FileObject.

Example

inputoutput

Usage for developers

Requirements

  • Python 3.10 or newer
  • Git LFS for the model checkpoint
  • CUDA-capable GPU is optional
git lfs pull
pip install -r requirements.txt

Run the demo

python demo.py path/to/road_scene.jpg --output depth_map.png

Use CPU explicitly when needed:

python demo.py path/to/road_scene.jpg --device cpu

Use the AIOZ entry point

import my_ai_lib
from aioz_ainode_adapter.schemas import InputObject

input_obj = InputObject(
    input_image="path/to/road_scene.jpg",
    device="cuda",
    model_storage_directory="models",
)
output_obj = my_ai_lib.run(input_obj)

print(output_obj.output_image.name)

The public API is my_ai_lib.run(input_obj). Task-specific schemas and inference logic live in my_ai_lib/run.py as MyInput, MyOutput, do_ai_task, and run.

Project structure

.
├── aioz_ainode_adapter/
├── assets/
│   ├── sample.png
├── models/
│   └── depth_estimation/
│       ├── config.json
│       ├── preprocessor_config.json
│       └── pytorch_model.bin
├── my_ai_lib/
│   ├── __init__.py
│   └── run.py
├── demo.py
├── README.md
└── requirements.txt

Limitations

  • Monocular depth is inherently ambiguous and can lose absolute metric scale.
  • Results can degrade on scenes that differ substantially from KITTI driving imagery (e.g. upward-angled architectural shots or complex indoor scenes).
  • KITTI LiDAR ground truth lacks data for the sky, which may introduce artifacts in open-sky regions.
  • The exported PNG is normalized for relative visualization; per-image normalization prevents direct numeric comparison between different images.
  • Very large images require additional CPU/GPU memory during interpolation.

References and attribution

License

The facebook/dpt-dinov2-base-kitti model and DINOv2 backbone are licensed under the Apache License 2.0. Please refer to the upstream repository for full license terms.

Citation

@misc{oquab2023dinov2,
      title={DINOv2: Learning Robust Visual Features without Supervision},
      author={Maxime Oquab and Timoth{\'e}e Darcet and Th{\'e}o Moutakanni and Huy Vo and Marc Szafraniec and Vasil Khalidov and Pierre Fernandez and Daniel Haziza and Francisco Massa and Alaaeldin El-Nouby and Mahmoud Assran and Nicolas Ballas and Wojciech Galuba and Russell Howes and Po-Yao Huang and Shang-Wen Li and Ishan Misra and Michael Rabbat and Vasu Sharma and Gabriel Synnaeve and Hu Xu and Herv{\'e} Jegou and Julien Mairal and Patrick Labatut and Armand Joulin and Piotr Bojanowski},
      year={2023},
      eprint={2304.07193},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}