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- Support tier
- Inference only, since v. Predict, validate and export only. Training features do not apply.
- Licenses
- Code MIT, weights MIT. Commercial use
Install
MiDaS needs no optional extra. Everything it imports is in the base install.
pip install libreyoloPredict
MiDaS is the one depth family LibreYOLO does not republish on its own Hugging
Face organization. Requesting a checkpoint by its LibreYOLO filename downloads
the matching official asset directly from the isl-org/MiDaS GitHub releases,
checks it against a pinned SHA-256, and wraps it with LibreYOLO's checkpoint
metadata before first use; later runs reuse the cached local file. See
Licensing for why.
from libreyolo import LibreYOLO, SAMPLE_IMAGE # Not on disk yet: LibreYOLO downloads it from the official isl-org/MiDaS# GitHub release and checks it against a pinned SHA-256 before use.model = LibreYOLO("LibreMiDaSl-depth.pt")result = model(SAMPLE_IMAGE, save=True) depth = result.depth_mapprint(depth.min, depth.max, depth.mean)libreyolo predict model=LibreMiDaSl-depth.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=Truefrom 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() does not cover this family, since it is defined for
surface normals and edges only. 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.
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"])libreyolo val model=LibreMiDaSl-depth.pt data=my-dataset.yamlExport
| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| depth | depth to ONNX: supported. | depth to TorchScript: supported. | depth to ExecuTorch: supported. | depth to TensorRT: supported. | depth to OpenVINO: supported. | depth to Paddle: not supported | depth to MNN: not supported | depth to RKNN: not supported | depth to ncnn: supported. | depth to TFLite: not supported | depth to CoreML: not supported | depth 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.
from libreyolo import LibreYOLO model = LibreYOLO("LibreMiDaSl-depth.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)libreyolo export model=LibreMiDaSl-depth.pt format=onnxlibreyolo export model=LibreMiDaSl-depth.pt format=tensorrt half=Truefrom 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
- Upstream source
- github.com/isl-org/MiDaS
- LibreYOLO code
- MIT
- Weights
- MIT, distributed by their authors. LibreYOLO does not host or mirror them.
- Interpretation
- The isl-org/MiDaS repository, code and released checkpoints included, is MIT. LibreYOLO's own port code is MIT as well. LibreYOLO does not republish the checkpoints on its own Hugging Face organization, though: the family downloads the two official release assets directly from GitHub and checks them against a pinned SHA-256 before wrapping them, because an internal LibreYOLO policy (ADR 0006) requires the training-dataset mixture's commercial-redistribution terms to be cleared before LibreYOLO hosts a depth checkpoint itself, and that clearance has not happened for MiDaS. The bytes you get are upstream's own MIT-licensed release either way.
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.