MiDaS

MiDaS is monocular relative depth estimation trained with scale-and-shift invariant loss across mixed datasets, the line of work that established the zero-shot depth transfer protocol later families reuse. LibreYOLO supports it for the depth task: predict and zero-shot validation, with no training path.

Tasks
depth
Sizes
s, l at 256 to 384 px
Install
pip install "libreyolo[midas]"
Support tier
Inference only, since v1.5.0. Predict, validate and export only. Training features do not apply.
Upstream
MiDaS by Intel Intelligent Systems Lab (Intel ISL), MIT. Paper, source
Licenses
Code MIT, weights MIT. Commercial use

Install

MiDaS needs the midas extra for its timm encoders.

bash
pip install "libreyolo[midas]"

Predict

The s and l checkpoints download from LibreYOLO's mirrors under the publisher's MIT grant and are cached locally.

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE # Downloads the mirrored checkpoint on first use.model = LibreYOLO("LibreMiDaSl-depth.pt")result = model(SAMPLE_IMAGE, save=True) depth = result.depth_mapprint(depth.min, depth.max, depth.mean)
CLI
libreyolo predict model=LibreMiDaSl-depth.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True
Small variant
from libreyolo import LibreYOLO, SAMPLE_IMAGE # EfficientNet-Lite3 encoder, smaller and faster than the DPT-Large l size.model = LibreYOLO("LibreMiDaSs-depth.pt")result = model(SAMPLE_IMAGE, save=True)

result.depth_map carries a dense relative inverse-depth map: higher values mean closer to the camera, and the values have no metric unit or cross-image scale. save=True writes a colormapped visualization of that map to disk; Results.plot() renders the depth map. See prediction for sources, streaming and result handling.

Variants

Two variants with different encoders, not just different scales of the same one. s is MiDaS v2.1 Small, an EfficientNet-Lite3 encoder. l is DPT-Large, a ViT-L/16 encoder with the DPT decoder MiDaS introduced for dense prediction. They also preprocess differently: s uses an upper-bound aspect resize with ImageNet mean/std normalization, l uses a minimal aspect resize with mean and std of 0.5. Pick s for a lighter CNN, l for the transformer decoder's accuracy.

Training is not offered for this family. LibreMiDaS.train() raises NotImplementedError unconditionally.

Validate

val() runs the shared depth validator: it aligns each prediction to its ground truth with a per-image least-squares scale and shift, then reports the standard zero-shot relative-depth metrics, AbsRel, RMSE and the three delta thresholds.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreMiDaSl-depth.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/abs_rel"])print(metrics["metrics/rmse"])print(metrics["metrics/delta1"])
CLI
libreyolo val model=LibreMiDaSl-depth.pt data=my-dataset.yaml

Export

TaskONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
DepthDepth to ONNX: supportedDepth to TorchScript: supportedDepth to ExecuTorch: supportedDepth to TensorRT: supportedDepth to OpenVINO: supportedDepth to Paddle: not supportedDepth to MNN: not supportedDepth to RKNN: not supportedDepth to ncnn: supportedDepth to TFLite: not supportedDepth to CoreML: not supportedDepth to Core AI: not supported

An exported artifact loads back through LibreYOLO() on its file suffix, so a .onnx or .engine file behaves like a checkpoint and returns the same Results, with depth_map in place of boxes.

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreMiDaSl-depth.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)
CLI
libreyolo export model=LibreMiDaSl-depth.pt format=onnxlibreyolo export model=LibreMiDaSl-depth.pt format=tensorrt half=True
Use the exported file
from libreyolo import LibreYOLO, SAMPLE_IMAGE # The factory routes on the file suffix, so an exported artifact loads# like any checkpoint and returns the same Results object.model = LibreYOLO("LibreMiDaSl-depth.onnx")result = model(SAMPLE_IMAGE) print(result.depth_map.data.shape)

Licensing

Check the license on the Hugging Face repository of the specific weights you download. Every checkpoint in the LibreYOLO org carries one, and they are not always the same across a family. That repository is the authoritative source; the summary below describes what applied when this page was last verified.

This is a description of the licenses involved, not legal advice. If the answer matters commercially, read the licenses yourself and take your own counsel.

Original work
MiDaS, Intel Intelligent Systems Lab (Intel ISL)
Upstream license
MIT
LibreYOLO code
MIT
Weights
MIT, republished at huggingface.co/LibreYOLO
Interpretation
The upstream repository and released weights declare MIT. LibreYOLO mirrors the s and l checkpoints under that publisher grant.

Citation

@ARTICLE {Ranftl2022,
    author  = "Ren\'{e} Ranftl and Katrin Lasinger and David Hafner and Konrad Schindler and Vladlen Koltun",
    title   = "Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-Shot Cross-Dataset Transfer",
    journal = "IEEE Transactions on Pattern Analysis and Machine Intelligence",
    year    = "2022",
    volume  = "44",
    number  = "3"
}

@article{Ranftl2021,
	author    = {Ren\'{e} Ranftl and Alexey Bochkovskiy and Vladlen Koltun},
	title     = {Vision Transformers for Dense Prediction},
	journal   = {ICCV},
	year      = {2021},
}

Copied from the authors' citation block at github.com/isl-org/MiDaS#citation.

Verified against LibreYOLO v1.6.0. Support tables, checkpoints and benchmark numbers on this page are generated from the released library and the published weights, not written by hand.

MiDaS architecture

Select a variant or family overview, then select a block for details. Open the full diagram to zoom or download SVG and PNG.