docs/en/datasets/depth/index.md
Monocular depth estimation assigns a floating-point depth value in meters to every pixel in an image. The training target is a dense per-pixel depth map stored as a .npy float32 array. Each value represents the distance from the camera to the corresponding scene point.
This guide explains the dataset format used by Ultralytics YOLO depth estimation models and lists the built-in dataset configurations available for training and validation.
Each training sample consists of one RGB image and one paired .npy depth file. The depth file stores a 2D float32 NumPy array with shape (H, W) where values are depths in meters.
.npy extension and contain a float32 array.scene_001.npy pairs with scene_001.jpg).images directory component with depth in the file path and swapping the image extension for .npy.≤ 0 are treated as invalid and excluded from loss and metric computation.The standard layout keeps images and depth maps in parallel folders:
dataset/
├── images/
│ ├── train/
│ └── val/
└── depth/
├── train/
└── val/
For example, an image at images/train/scene_001.jpg is paired with a depth map at depth/train/scene_001.npy.
Depth estimation datasets are configured with YAML files. The main fields are:
| Key | Description |
|---|---|
path | Dataset root directory. |
train | Training image path relative to path, or an absolute path. |
val | Validation image path relative to path, or an absolute path. |
test | Optional test image path. |
nc | Number of classes — always 1 for depth estimation. |
names | Class name mapping — always {0: depth}. |
!!! example "ultralytics/cfg/datasets/nyu-depth.yaml"
```yaml
--8<-- "ultralytics/cfg/datasets/nyu-depth.yaml"
```
Train a YOLO26 depth estimation model with Python or CLI:
!!! example
=== "Python"
```python
from ultralytics import YOLO
# Load a pretrained depth model
model = YOLO("yolo26n-depth.pt")
# Train on the NYU Depth V2 dataset
results = model.train(data="nyu-depth.yaml", epochs=100, imgsz=640)
```
=== "CLI"
```bash
yolo depth train data=nyu-depth.yaml model=yolo26n-depth.pt epochs=100 imgsz=640
```
The YOLO26 depth models are pretrained on a broad multi-dataset mix (~2.19M images) spanning indoor (≤10 m) to outdoor (~80 m) ranges, then evaluated zero-shot across five benchmarks. Each dataset has a dedicated page:
Debugging
Pretraining sources
Evaluation benchmarks
Per-model accuracy on these benchmarks and the downloadable pretrained weights are listed on the Depth Estimation task page. A dataset YAML whose train field lists multiple image directories combines these sources for large-scale mixed training.
images/train and images/val..npy float32 depth array per image under the matching depth/train and depth/val folders using the same file stem as the image.0 or negative values.path, train, val, nc: 1, and names: {0: depth}.path: path/to/my-depth-dataset
train: images/train
val: images/val
nc: 1
names:
0: depth
Depth maps must be saved as NumPy .npy files containing float32 arrays of shape (H, W). Each element stores the depth in meters for the corresponding image pixel. Do not use PNG or 16-bit integer formats — the loader expects raw float arrays.
Pixels with depth values ≤ 0 are treated as invalid and masked out from both loss computation and metric evaluation. This covers sensor noise, sky regions, and reflective surfaces where depth cannot be reliably measured.
Depth estimation validation reports the standard Depth Anything metric set:
Yes. Each depth .npy file must share the same stem as the corresponding image. The loader derives the depth path by replacing the images directory component with depth and substituting the image extension for .npy. Images whose depth file is missing or unreadable are dropped during the (cached) dataset scan with a warning, exactly like corrupt images; if no valid image-depth pairs are found at all, an error is raised.