flyingbertman commited on
Commit
4240d18
Β·
verified Β·
1 Parent(s): 2f457d3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +74 -0
README.md CHANGED
@@ -1,3 +1,77 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ library_name: onnx
4
+ tags:
5
+ - depth-estimation
6
+ - midas
7
+ - mobile
8
+ - edge
9
+ - onnx
10
+ base_model: isl-org/MiDaS
11
+ pipeline_tag: depth-estimation
12
+ language:
13
+ - en
14
  ---
15
+
16
+ # MiDaS v2.1 Small β€” Monocular Depth Estimation (ONNX)
17
+
18
+ ONNX checkpoint of [Intel ISL's MiDaS v2.1 small](https://github.com/isl-org/MiDaS) β€” an EfficientNet-Lite3 encoder paired with a lightweight depth decoder. ~21M params, 256Γ—256 input, CPU-friendly. Sibling to DPT-Large but ~16Γ— smaller and ~20Γ— faster on CPU.
19
+
20
+ Not converted locally β€” this is the ONNX file isl-org publishes directly in the [v2_1 GitHub release](https://github.com/isl-org/MiDaS/releases/tag/v2_1).
21
+
22
+ Credit: Intel Intelligent Systems Lab (MiDaS team β€” Ranftl, Lasinger, Hafner, Schindler, Koltun).
23
+
24
+ ## What this repo contains
25
+
26
+ ```
27
+ midas_v21_small_256.onnx # ~80 MB β€” fp32, EfficientNet-Lite3 backbone, 256Γ—256 input
28
+ ```
29
+
30
+ A single ONNX file. No tokenizer, no preprocessor config β€” preprocessing is fixed by the architecture convention.
31
+
32
+ ## Input / output
33
+
34
+ | | Spec |
35
+ |---|---|
36
+ | Input name | `input.1` (verify in Netron) |
37
+ | Input shape | `[1, 3, 256, 256]` (NCHW) |
38
+ | Input dtype | float32 |
39
+ | Input color order | **BGR** β€” note this differs from DPT-Large (which expects RGB) |
40
+ | Preprocessing | Resize to 256Γ—256, scale to `[0,1]`, normalize with ImageNet stats: `mean=[0.485, 0.456, 0.406]`, `std=[0.229, 0.224, 0.225]` |
41
+ | Output shape | `[1, 256, 256]` |
42
+ | Output meaning | Single-channel **relative** depth (higher = closer, lower = farther). **Not metric.** Linearly map to your visualization range. |
43
+
44
+ ## How to use
45
+
46
+ ```python
47
+ import onnxruntime as ort
48
+ import numpy as np
49
+ from PIL import Image
50
+
51
+ sess = ort.InferenceSession("midas_v21_small_256.onnx")
52
+
53
+ # Resize, BGR (note: PIL is RGB by default β€” swap channels for MiDaS-small)
54
+ img = Image.open("photo.jpg").convert("RGB").resize((256, 256))
55
+ arr = np.asarray(img, dtype=np.float32) / 255.0
56
+ arr = arr[..., ::-1] # RGB -> BGR
57
+ arr = (arr - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225] # ImageNet normalize
58
+ arr = arr.transpose(2, 0, 1)[None, ...].copy().astype(np.float32) # NCHW
59
+
60
+ depth = sess.run(None, {sess.get_inputs()[0].name: arr})[0][0] # 256x256
61
+ ```
62
+
63
+ For metric depth, pair with a calibration scheme β€” MiDaS is trained for relative depth and will not give you "this object is 1.7 m away" without further work.
64
+
65
+ ## When to pick MiDaS-small
66
+
67
+ - **Real-time, edge, CPU, or mobile**: ~50 ms / image on consumer CPU, ~80 MB on disk.
68
+ - **Coarse depth is enough**: relative ordering of "what's close vs far" matters more than fine boundary precision.
69
+ - **Pair with DPT-Large**: a common pattern is to run MiDaS-small first for a quick estimate, then fall back to DPT-Large only when high-quality depth is needed for a specific frame.
70
+
71
+ For sharper boundaries and higher absolute quality (at ~16Γ— the disk + GPU latency), reach for `dpt-large` instead β€” same model family, same upstream lab.
72
+
73
+ ## License
74
+
75
+ **MIT** β€” same as the upstream [isl-org/MiDaS](https://github.com/isl-org/MiDaS) repo. `LICENSE` file included.
76
+
77
+ Note: a separate Intel-published variant of DPT-Large lives on HuggingFace at `Intel/dpt-large` under **Apache-2.0**. Same model family, different distribution channel, different licenses. The checkpoint in *this* repo (v2_1 GitHub release) inherits MIT from the upstream GitHub repo.