lihongjie
commited on
Commit
·
dcf454d
1
Parent(s):
2dc6cb1
first commit
Browse files- .gitattributes +30 -0
- README.md +90 -3
- examples/demo01.jpg +3 -0
- examples/demo02.jpg +3 -0
- examples/demo03.jpg +3 -0
- examples/demo04.jpg +3 -0
- examples/demo05.jpg +3 -0
- examples/demo06.jpg +3 -0
- examples/demo07.jpg +3 -0
- examples/demo08.jpg +3 -0
- examples/demo09.jpg +3 -0
- examples/demo10.jpg +3 -0
- examples/demo11.jpg +3 -0
- examples/demo12.jpg +3 -0
- examples/demo13.jpg +3 -0
- examples/demo14.jpg +3 -0
- examples/demo15.jpg +3 -0
- examples/demo16.jpg +3 -0
- examples/demo17.jpg +3 -0
- examples/demo18.jpg +3 -0
- examples/demo19.jpg +3 -0
- examples/demo20.jpg +3 -0
- models/da3-base.axmodel +3 -0
- models/da3-base.onnx +3 -0
- models/da3-small.axmodel +3 -0
- models/da3-small.onnx +3 -0
- models/da3metric-large.axmodel +3 -0
- models/da3metric-large.onnx +3 -0
- models/da3mono-large.axmodel +3 -0
- models/da3mono-large.onnx +3 -0
- output-ax.png +3 -0
- output-onnx.png +3 -0
- python/infer.py +50 -0
- python/infer_onnx.py +56 -0
- python/requirements.txt +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,33 @@ saved_model/**/* 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 36 |
+
examples/demo16.jpg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
models/da3-base.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
models/da3-base.onnx filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
examples/demo04.jpg filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
examples/demo08.jpg filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
models/da3mono-large.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
output-ax.png filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
examples/demo19.jpg filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
examples/demo02.jpg filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
examples/demo10.jpg filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
examples/demo11.jpg filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
examples/demo15.jpg filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
examples/demo12.jpg filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
examples/demo20.jpg filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
models/da3-small.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
output-onnx.png filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
examples/demo05.jpg filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
examples/demo06.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
examples/demo14.jpg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
models/da3metric-large.onnx filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
examples/demo13.jpg filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
examples/demo17.jpg filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
examples/demo09.jpg filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
examples/demo18.jpg filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
models/da3mono-large.onnx filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
models/da3-small.onnx filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
examples/demo01.jpg filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
examples/demo03.jpg filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
examples/demo07.jpg filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
models/da3metric-large.axmodel filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,90 @@
|
|
| 1 |
-
---
|
| 2 |
-
license:
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: bsd-3-clause
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
base_model:
|
| 6 |
+
- depth-anything/DA3-SMALL
|
| 7 |
+
- depth-anything/DA3-BASE
|
| 8 |
+
- depth-anything/DA3MONO-LARGE
|
| 9 |
+
- depth-anything/DA3METRIC-LARGE
|
| 10 |
+
pipeline_tag: depth-estimation
|
| 11 |
+
tags:
|
| 12 |
+
- Depth-Anything-3
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Depth-Anything-3
|
| 16 |
+
|
| 17 |
+
This version of Depth-Anything-3 has been converted to run on the Axera NPU using **w8a16** quantization.
|
| 18 |
+
|
| 19 |
+
This model has been optimized with the following LoRA:
|
| 20 |
+
|
| 21 |
+
Compatible with Pulsar2 version: 3.4
|
| 22 |
+
|
| 23 |
+
## Convert tools links:
|
| 24 |
+
|
| 25 |
+
For those who are interested in model conversion, you can try to export axmodel through
|
| 26 |
+
|
| 27 |
+
- [The repo of original](https://github.com/ByteDance-Seed/Depth-Anything-3)
|
| 28 |
+
|
| 29 |
+
- [The repo of AXera Platform](https://github.com/AXERA-TECH/Depth-Anything-3.AXERA.git), which you can get the detial of guide
|
| 30 |
+
|
| 31 |
+
- [Pulsar2 Link, How to Convert ONNX to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/pulsar2/introduction.html)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
## Support Platform
|
| 35 |
+
|
| 36 |
+
- AX650
|
| 37 |
+
- [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html)
|
| 38 |
+
- [M.2 Accelerator card](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html)
|
| 39 |
+
- AX630C
|
| 40 |
+
- [爱芯派2](https://axera-pi-2-docs-cn.readthedocs.io/zh-cn/latest/index.html)
|
| 41 |
+
- [Module-LLM](https://docs.m5stack.com/zh_CN/module/Module-LLM)
|
| 42 |
+
- [LLM630 Compute Kit](https://docs.m5stack.com/zh_CN/core/LLM630%20Compute%20Kit)
|
| 43 |
+
|
| 44 |
+
|Chips|Time|
|
| 45 |
+
|--|--|
|
| 46 |
+
|AX650| ms |
|
| 47 |
+
|AX630C| ms |
|
| 48 |
+
|
| 49 |
+
## How to use
|
| 50 |
+
|
| 51 |
+
Download all files from this repository to the device
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
### python env requirement
|
| 55 |
+
|
| 56 |
+
#### pyaxengine
|
| 57 |
+
|
| 58 |
+
https://github.com/AXERA-TECH/pyaxengine
|
| 59 |
+
|
| 60 |
+
```
|
| 61 |
+
wget https://github.com/AXERA-TECH/pyaxengine/releases/download/0.1.3.rc2/axengine-0.1.3-py3-none-any.whl
|
| 62 |
+
pip install axengine-0.1.3-py3-none-any.whl
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
#### others
|
| 66 |
+
|
| 67 |
+
Maybe None.
|
| 68 |
+
|
| 69 |
+
#### Inference with AX650 Host, such as M4N-Dock(爱芯派Pro)
|
| 70 |
+
|
| 71 |
+
Input image:
|
| 72 |
+
|
| 73 |
+

|
| 74 |
+
|
| 75 |
+
```
|
| 76 |
+
root@ax650:~/AXERA-TECH/Depth-Anything-3# python3 python/infer.py --model models/da3metric-large.axmodel --img examples/demo01.jpg
|
| 77 |
+
[INFO] Available providers: ['AxEngineExecutionProvider']
|
| 78 |
+
[INFO] Using provider: AxEngineExecutionProvider
|
| 79 |
+
[INFO] Chip type: ChipType.MC50
|
| 80 |
+
[INFO] VNPU type: VNPUType.DISABLED
|
| 81 |
+
[INFO] Engine version: 2.12.0s
|
| 82 |
+
[INFO] Model type: 2 (triple core)
|
| 83 |
+
[INFO] Compiler version: 3.3 ae03a08f
|
| 84 |
+
root@ax650:~/AXERA-TECH/Depth-Anything-3# ls
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
Output image:
|
| 88 |
+
|
| 89 |
+

|
| 90 |
+
|
examples/demo01.jpg
ADDED
|
Git LFS Details
|
examples/demo02.jpg
ADDED
|
Git LFS Details
|
examples/demo03.jpg
ADDED
|
Git LFS Details
|
examples/demo04.jpg
ADDED
|
Git LFS Details
|
examples/demo05.jpg
ADDED
|
Git LFS Details
|
examples/demo06.jpg
ADDED
|
Git LFS Details
|
examples/demo07.jpg
ADDED
|
Git LFS Details
|
examples/demo08.jpg
ADDED
|
Git LFS Details
|
examples/demo09.jpg
ADDED
|
Git LFS Details
|
examples/demo10.jpg
ADDED
|
Git LFS Details
|
examples/demo11.jpg
ADDED
|
Git LFS Details
|
examples/demo12.jpg
ADDED
|
Git LFS Details
|
examples/demo13.jpg
ADDED
|
Git LFS Details
|
examples/demo14.jpg
ADDED
|
Git LFS Details
|
examples/demo15.jpg
ADDED
|
Git LFS Details
|
examples/demo16.jpg
ADDED
|
Git LFS Details
|
examples/demo17.jpg
ADDED
|
Git LFS Details
|
examples/demo18.jpg
ADDED
|
Git LFS Details
|
examples/demo19.jpg
ADDED
|
Git LFS Details
|
examples/demo20.jpg
ADDED
|
Git LFS Details
|
models/da3-base.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:02f0291bb629de91860a17174351c82825a975f4979100882399219f39764ea6
|
| 3 |
+
size 139250301
|
models/da3-base.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5a9193dca2e27df2fa5cd3bac074afcf3d662a9939869f4177aeacf4eba73061
|
| 3 |
+
size 451237395
|
models/da3-small.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f9563bff5bde0aff1ce69ae026691035207d4c813fc5190ab118adff8da77366
|
| 3 |
+
size 40927267
|
models/da3-small.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82b0da30b20e48b968b718588a3a0cb296d0df5cc09327e0bd3301343edf9e9f
|
| 3 |
+
size 124726109
|
models/da3metric-large.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7f65d9248e36663e989c926653a6f411aecbd822504c4c1364be05f22174e0c9
|
| 3 |
+
size 382403608
|
models/da3metric-large.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:500faa78858c1b646b0e39974128479bf313a0b10c6071b47161c34fc308c17f
|
| 3 |
+
size 1334346787
|
models/da3mono-large.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d70bb9242c90ad9425733d8aacd27d18d520f2e5f6f15f86efd08d9035a8745
|
| 3 |
+
size 382396604
|
models/da3mono-large.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:166946c445e7be229fa20a87ea445d9b2f11b484d171915a273a9757b60e1f01
|
| 3 |
+
size 1334346787
|
output-ax.png
ADDED
|
Git LFS Details
|
output-onnx.png
ADDED
|
Git LFS Details
|
python/infer.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
import axengine as axe
|
| 5 |
+
|
| 6 |
+
def parse_args() -> argparse.Namespace:
|
| 7 |
+
parser = argparse.ArgumentParser()
|
| 8 |
+
parser.add_argument(
|
| 9 |
+
"--img",
|
| 10 |
+
type=str,
|
| 11 |
+
required=True,
|
| 12 |
+
help="Path to input image.",
|
| 13 |
+
)
|
| 14 |
+
parser.add_argument(
|
| 15 |
+
"--model",
|
| 16 |
+
type=str,
|
| 17 |
+
required=True,
|
| 18 |
+
help="Path to axmodel model.",
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
return parser.parse_args()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def infer(img: str, model: str, viz: bool = False):
|
| 25 |
+
img_raw = cv2.imread(img)
|
| 26 |
+
image = cv2.cvtColor(img_raw, cv2.COLOR_BGR2RGB)
|
| 27 |
+
orig_h, orig_w = image.shape[:2]
|
| 28 |
+
image = cv2.resize(image, (504,280))
|
| 29 |
+
image = image[None]
|
| 30 |
+
|
| 31 |
+
session = axe.InferenceSession(model)
|
| 32 |
+
|
| 33 |
+
depth = session.run(None, {"img": image})[0]
|
| 34 |
+
|
| 35 |
+
depth = cv2.resize(depth[0, 0], (orig_w, orig_h))
|
| 36 |
+
depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0
|
| 37 |
+
depth = depth.astype(np.uint8)
|
| 38 |
+
|
| 39 |
+
depth_color = cv2.applyColorMap(depth, cv2.COLORMAP_INFERNO)
|
| 40 |
+
|
| 41 |
+
combined_result = cv2.hconcat([img_raw, depth_color])
|
| 42 |
+
|
| 43 |
+
cv2.imwrite("output-ax.png", combined_result)
|
| 44 |
+
|
| 45 |
+
return depth
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
if __name__ == "__main__":
|
| 49 |
+
args = parse_args()
|
| 50 |
+
infer(**vars(args))
|
python/infer_onnx.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
import onnxruntime as ort
|
| 5 |
+
|
| 6 |
+
def parse_args() -> argparse.Namespace:
|
| 7 |
+
parser = argparse.ArgumentParser()
|
| 8 |
+
parser.add_argument(
|
| 9 |
+
"--img",
|
| 10 |
+
type=str,
|
| 11 |
+
required=True,
|
| 12 |
+
help="Path to input image.",
|
| 13 |
+
)
|
| 14 |
+
parser.add_argument(
|
| 15 |
+
"--model",
|
| 16 |
+
type=str,
|
| 17 |
+
required=True,
|
| 18 |
+
help="Path to ONNX model.",
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
return parser.parse_args()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def infer(img: str, model: str, viz: bool = False):
|
| 25 |
+
img_raw = cv2.imread(img)
|
| 26 |
+
image = cv2.cvtColor(img_raw, cv2.COLOR_BGR2RGB)
|
| 27 |
+
orig_h, orig_w = image.shape[:2]
|
| 28 |
+
image = cv2.resize(image, (504,280))
|
| 29 |
+
mean = np.array([123.675, 116.28, 103.53],dtype=np.float32).reshape(1,1,3)
|
| 30 |
+
std = np.array([58.395, 57.12, 57.375],dtype=np.float32).reshape(1,1,3)
|
| 31 |
+
|
| 32 |
+
image = (image-mean)/std
|
| 33 |
+
image = image.transpose(2,0,1)
|
| 34 |
+
image = image[None]
|
| 35 |
+
|
| 36 |
+
session = ort.InferenceSession(
|
| 37 |
+
model, providers=["CUDAExecutionProvider", "CPUExecutionProvider"]
|
| 38 |
+
)
|
| 39 |
+
depth = session.run(None, {"img": image})[0]
|
| 40 |
+
|
| 41 |
+
depth = cv2.resize(depth[0, 0], (orig_w, orig_h))
|
| 42 |
+
depth = (depth - depth.min()) / (depth.max() - depth.min()) * 255.0
|
| 43 |
+
depth = depth.astype(np.uint8)
|
| 44 |
+
|
| 45 |
+
depth_color = cv2.applyColorMap(depth, cv2.COLORMAP_INFERNO)
|
| 46 |
+
|
| 47 |
+
combined_result = cv2.hconcat([img_raw, depth_color])
|
| 48 |
+
|
| 49 |
+
cv2.imwrite("output-onnx.png", combined_result)
|
| 50 |
+
|
| 51 |
+
return depth
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
args = parse_args()
|
| 56 |
+
infer(**vars(args))
|
python/requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
onnx
|
| 2 |
+
onnxruntime
|
| 3 |
+
opencv-python
|