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
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
- Model details
- Parameters
- Example
- Usage for developers
- Project structure
- Limitations
- References and attribution
- License
- Citation
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
| Item | Value |
|---|---|
| Task | Monocular depth estimation |
| Architecture | DPT (Dense Prediction Transformer) |
| Backbone | DINOv2 Base (dinov2-base, ViT-B/14) |
| Framework | PyTorch / Hugging Face Transformers (transformers>=4.35.0) |
| Checkpoint | models/depth_estimation |
| Training domain | KITTI Vision Benchmark (autonomous driving) |
| Backbone resolution | 518 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, orgpu. The default iscuda; execution falls back to CPU when CUDA is unavailable.model_storage_directory(string, optional): Parent directory containingdepth_estimation. AIOZ supplies this value at runtime.
Output
output_image(image): A normalized disparity depth-map PNG nameddepth_map.pngwrapped in an AIOZFileObject.
Example
input | output |
|---|---|
![]() | ![]() |
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
- Original model repository: facebook/dpt-dinov2-base-kitti on Hugging Face by Meta AI.
- DINOv2 paper: DINOv2: Learning Robust Visual Features without Supervision (Oquab et al., 2023).
- DPT paper: Vision Transformers for Dense Prediction (Ranftl et al., ICCV 2021).
- Training dataset: The KITTI Vision Benchmark Suite (Geiger et al., CVPR 2012).
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}
}

