Kyle Pearson commited on
Commit ·
81a6f87
1
Parent(s): 3834869
docs
Browse files- .gitattributes +4 -33
- .gitignore +9 -0
- README.md +150 -3
.gitattributes
CHANGED
|
@@ -1,35 +1,6 @@
|
|
| 1 |
-
|
| 2 |
-
*.
|
| 3 |
-
*.
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
+
# Git LFS for large model files
|
| 2 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.mlpackage filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.weight.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 6 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.pyc
|
| 3 |
+
*.pyo
|
| 4 |
+
*.egg-info/
|
| 5 |
+
dist/
|
| 6 |
+
build/
|
| 7 |
+
.eggs/
|
| 8 |
+
*.egg
|
| 9 |
+
.DS_Store
|
README.md
CHANGED
|
@@ -1,3 +1,150 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- coreml
|
| 5 |
+
- depth-estimation
|
| 6 |
+
- computer-vision
|
| 7 |
+
- ios
|
| 8 |
+
- macos
|
| 9 |
+
- panorama
|
| 10 |
+
- vision
|
| 11 |
+
pipeline_tag: depth-estimation
|
| 12 |
+
base_model: Insta360-Research/DAP-weights
|
| 13 |
+
tags:
|
| 14 |
+
- coreml
|
| 15 |
+
- monocular-depth-estimation
|
| 16 |
+
- panorama-depth-estimation
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# DAP CoreML — Panoramic Depth Estimation for Apple Silicon
|
| 20 |
+
|
| 21 |
+
CoreML export of **[DAP (Depth Any Panoramas)](https://github.com/Insta360-Research-Team/DAP)**, a foundation model for monocular depth estimation on equirectangular 360° panoramas. Optimized for on-device inference on iOS 18+ and macOS with Apple Silicon.
|
| 22 |
+
|
| 23 |
+
| | |
|
| 24 |
+
|---|---|
|
| 25 |
+
| **Original model** | [DAP (Insta360 Research)](https://huggingface.co/Insta360-Research/DAP-weights) |
|
| 26 |
+
| **Architecture** | Depth-Anything-V2 + DINOv3 (ViT-L) |
|
| 27 |
+
| **Input** | Equirectangular panorama, 2:1 aspect ratio (default 1024×512) |
|
| 28 |
+
| **Output** | Monocular depth map, float32, same resolution as input |
|
| 29 |
+
| **CoreML size** | ~1.2 GB |
|
| 30 |
+
| **Deployment** | iOS 18+, macOS 15+ (Apple Silicon) |
|
| 31 |
+
|
| 32 |
+
## Validation
|
| 33 |
+
|
| 34 |
+
Exported and validated against PyTorch ground truth:
|
| 35 |
+
|
| 36 |
+
| Metric | Value |
|
| 37 |
+
|---|---|
|
| 38 |
+
| Max absolute difference | 5.54×10⁻⁶ |
|
| 39 |
+
| Mean absolute difference | 4.50×10⁻⁷ |
|
| 40 |
+
| Correlation | 1.000000 |
|
| 41 |
+
| CoreML inference (M-series) | ~650 ms |
|
| 42 |
+
|
| 43 |
+

|
| 44 |
+
|
| 45 |
+
## Quick Start — CLI (macOS)
|
| 46 |
+
|
| 47 |
+
Compile and run `DepthPredictor.swift` as a standalone tool — no Xcode project needed:
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
# Compile
|
| 51 |
+
swiftc -O -o depth_predictor DepthPredictor.swift \
|
| 52 |
+
-framework CoreML -framework Vision -framework CoreImage \
|
| 53 |
+
-framework CoreGraphics -framework AppKit
|
| 54 |
+
|
| 55 |
+
# Generate a 16-bit grayscale depth map
|
| 56 |
+
./depth_predictor -m DAPModel.mlpackage -i panorama.jpg -o depth.png
|
| 57 |
+
|
| 58 |
+
# Colorized with jet colormap
|
| 59 |
+
./depth_predictor -m DAPModel.mlpackage -i panorama.jpg -o depth.png -c jet
|
| 60 |
+
|
| 61 |
+
# Turbo colormap
|
| 62 |
+
./depth_predictor -m DAPModel.mlpackage -i panorama.jpg -o depth.png -c turbo
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
Options:
|
| 66 |
+
|
| 67 |
+
| Flag | Description |
|
| 68 |
+
|---|---|
|
| 69 |
+
| `-m, --model PATH` | Path to `DAPModel.mlpackage` or `.mlmodelc` |
|
| 70 |
+
| `-i, --input PATH` | Input equirectangular panorama (2:1 aspect ratio) |
|
| 71 |
+
| `-o, --output PATH` | Output PNG file |
|
| 72 |
+
| `-c, --colormap STYLE` | `grayscale` (16-bit, default), `jet`, or `turbo` |
|
| 73 |
+
|
| 74 |
+
The model is automatically compiled on first use and cached for subsequent runs.
|
| 75 |
+
|
| 76 |
+
## Quick Start — Xcode (iOS / macOS)
|
| 77 |
+
|
| 78 |
+
Add `DAPModel.mlpackage` to your Xcode project (Xcode auto-generates the `DAPModel` Swift class), then use the included `DepthPredictor.swift`:
|
| 79 |
+
|
| 80 |
+
```swift
|
| 81 |
+
import Foundation
|
| 82 |
+
import CoreML
|
| 83 |
+
import Vision
|
| 84 |
+
import CoreImage
|
| 85 |
+
|
| 86 |
+
// Load the model from a .mlpackage URL
|
| 87 |
+
let modelURL = Bundle.main.url(forResource: "DAPModel", withExtension: "mlpackage")!
|
| 88 |
+
let predictor = DepthPredictor(modelURL: modelURL)
|
| 89 |
+
|
| 90 |
+
// Run inference on a CGImage (equirectangular panorama)
|
| 91 |
+
predictor.predictDepth(from: cgImage) { depth in
|
| 92 |
+
guard let depth = depth else { return }
|
| 93 |
+
// `depth` is a DepthResult with raw Float32 values and a CIImage
|
| 94 |
+
|
| 95 |
+
// Colorize with jet colormap
|
| 96 |
+
let colorized = predictor.applyJetColormap(to: depth)
|
| 97 |
+
|
| 98 |
+
// Or access raw depth values directly
|
| 99 |
+
let values = depth.getDepthValues() // [Float32], row-major
|
| 100 |
+
}
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
## Files
|
| 104 |
+
|
| 105 |
+
| File | Description |
|
| 106 |
+
|---|---|
|
| 107 |
+
| `DAPModel.mlpackage/` | CoreML model (depth-only, ImageType input) |
|
| 108 |
+
| `model.pth` | Original DAP PyTorch weights |
|
| 109 |
+
| `export_and_validate_coreml.py` | Export + validation script |
|
| 110 |
+
| `DepthPredictor.swift` | Swift inference wrapper |
|
| 111 |
+
| `depth_anything_utils.py` | Image preprocessing utilities |
|
| 112 |
+
| `networks/` | DAP model definition |
|
| 113 |
+
| `depth_anything_v2_metric/` | Depth-Anything-V2 + DINOv3 backbone |
|
| 114 |
+
| `test/test.png` | Test panorama for validation |
|
| 115 |
+
| `test_output/` | PyTorch vs CoreML comparison |
|
| 116 |
+
|
| 117 |
+
## Export from Scratch
|
| 118 |
+
|
| 119 |
+
Reproduce the CoreML model from the PyTorch weights:
|
| 120 |
+
|
| 121 |
+
```bash
|
| 122 |
+
# Install dependencies
|
| 123 |
+
pip install -r requirements.txt
|
| 124 |
+
|
| 125 |
+
# Export and validate (produces DAPModel.mlpackage + test_output/)
|
| 126 |
+
python export_and_validate_coreml.py
|
| 127 |
+
|
| 128 |
+
# Custom resolution (must be multiples of 16)
|
| 129 |
+
python export_and_validate_coreml.py --height 768 --width 1536
|
| 130 |
+
|
| 131 |
+
# Skip export, only validate existing model
|
| 132 |
+
python export_and_validate_coreml.py --skip_export
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
## Citation
|
| 136 |
+
|
| 137 |
+
```bibtex
|
| 138 |
+
@article{lin2025dap,
|
| 139 |
+
title={Depth Any Panoramas: A Foundation Model for Panoramic Depth Estimation},
|
| 140 |
+
author={Lin, Xin and Song, Meixi and Zhang, Dizhe and Lu, Wenxuan and Li, Haodong and Du, Bo and Yang, Ming-Hsuan and Nguyen, Truong and Qi, Lu},
|
| 141 |
+
journal={arXiv},
|
| 142 |
+
year={2025}
|
| 143 |
+
}
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
## License
|
| 147 |
+
|
| 148 |
+
Original DAP weights and model architecture: **MIT** ([Insta360 Research Team](https://github.com/Insta360-Research-Team/DAP))
|
| 149 |
+
|
| 150 |
+
CoreML export and Swift wrapper: **MIT**
|