lihongjie commited on
Commit
dcf454d
·
1 Parent(s): 2dc6cb1

first commit

Browse files
.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: mit
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
+ ![](examples/demo01.jpg)
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
+ ![](output-ax.png)
90
+
examples/demo01.jpg ADDED

Git LFS Details

  • SHA256: 35ef1bbb63f6540e49aa9b6302b9b938be4fe8b9c08c07c3694b02396b0e87e0
  • Pointer size: 131 Bytes
  • Size of remote file: 488 kB
examples/demo02.jpg ADDED

Git LFS Details

  • SHA256: c1f116034aa5abd5b5470226be2bb03bd938c8affe90389c52d10fe8b1ac7e21
  • Pointer size: 131 Bytes
  • Size of remote file: 511 kB
examples/demo03.jpg ADDED

Git LFS Details

  • SHA256: 764dffd4d97bbacd620bc005fa86837018393ccb5ffd1059c2245a3cacff7782
  • Pointer size: 131 Bytes
  • Size of remote file: 465 kB
examples/demo04.jpg ADDED

Git LFS Details

  • SHA256: 3a301f4e0361fe75ca4d256a35062f87eecc3f7655d747c9def3259c86e26a45
  • Pointer size: 131 Bytes
  • Size of remote file: 300 kB
examples/demo05.jpg ADDED

Git LFS Details

  • SHA256: 50e7e2f057c5a2d27bb09b0b3e814147966e30139ddaf54362c72746a5320339
  • Pointer size: 131 Bytes
  • Size of remote file: 353 kB
examples/demo06.jpg ADDED

Git LFS Details

  • SHA256: 0fd815bddeab139e7477c948a22fffdf84d9b87f81d77dcf6fd8ef39ebaaafb5
  • Pointer size: 131 Bytes
  • Size of remote file: 783 kB
examples/demo07.jpg ADDED

Git LFS Details

  • SHA256: 345bec735adc4c238bf14ddf1d182c4881f8ba08814c4f4074c1d79e9e4adc52
  • Pointer size: 131 Bytes
  • Size of remote file: 400 kB
examples/demo08.jpg ADDED

Git LFS Details

  • SHA256: d32b480349013be5f84521b0df1d6590139163aef8457f051076ed03c7371e6f
  • Pointer size: 131 Bytes
  • Size of remote file: 103 kB
examples/demo09.jpg ADDED

Git LFS Details

  • SHA256: 6a64033ba69bb408c092dbff811abfbcb0196f1f87541902d03d2a909a0b8ea9
  • Pointer size: 131 Bytes
  • Size of remote file: 410 kB
examples/demo10.jpg ADDED

Git LFS Details

  • SHA256: bc77f215081f58de8d079e821e2808f6ee2727dfa729c10a5921c186a32c7638
  • Pointer size: 131 Bytes
  • Size of remote file: 487 kB
examples/demo11.jpg ADDED

Git LFS Details

  • SHA256: 150ef98e997ee6ff705bd06105c343f76a8f181ef93ff9ceebbd62a3ab6b592b
  • Pointer size: 131 Bytes
  • Size of remote file: 244 kB
examples/demo12.jpg ADDED

Git LFS Details

  • SHA256: 264458adcf5af6e3733dfda7ef4628c4a1dc49ed249aa8896256d9534a8377c4
  • Pointer size: 131 Bytes
  • Size of remote file: 263 kB
examples/demo13.jpg ADDED

Git LFS Details

  • SHA256: 9168fc752a002d50138a56621e8de5fab7fed125a978dd293319d28d30993564
  • Pointer size: 131 Bytes
  • Size of remote file: 421 kB
examples/demo14.jpg ADDED

Git LFS Details

  • SHA256: 01480d952bc950332f0eea31da0777f66d5f285d8edfe2a5f47508f4b260a99f
  • Pointer size: 131 Bytes
  • Size of remote file: 643 kB
examples/demo15.jpg ADDED

Git LFS Details

  • SHA256: bf60ce3879f627e8886280cc61442174c91908894a5b059681341fed600f7db3
  • Pointer size: 131 Bytes
  • Size of remote file: 769 kB
examples/demo16.jpg ADDED

Git LFS Details

  • SHA256: a92e51732b38ad8b21b5cbbc6883374bd5ab56bb4907d6c4f1e13307970480ee
  • Pointer size: 131 Bytes
  • Size of remote file: 378 kB
examples/demo17.jpg ADDED

Git LFS Details

  • SHA256: 7174dcfbbb95a2e581ebf1e14cfbb4bef7a1295ae9cece405c87145223dcb32d
  • Pointer size: 131 Bytes
  • Size of remote file: 153 kB
examples/demo18.jpg ADDED

Git LFS Details

  • SHA256: 4deeb16dbee40108f194bd87c8621416110427c8ab5fc5ad6a1d9002b2b620c2
  • Pointer size: 131 Bytes
  • Size of remote file: 179 kB
examples/demo19.jpg ADDED

Git LFS Details

  • SHA256: 7cdb09c34eb0b4d2ac5f6070aec47c8f983a0b1b2c9ee1fc30decafb64f1bd98
  • Pointer size: 132 Bytes
  • Size of remote file: 1 MB
examples/demo20.jpg ADDED

Git LFS Details

  • SHA256: 2958fd1b7018e40b68ccc8d74ff8e50bf143f5046711d57c54eec2a479550ace
  • Pointer size: 131 Bytes
  • Size of remote file: 498 kB
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

  • SHA256: 16896a7a40bf37eac65316d0ec74afa99c7dc3d390aa88f84f4aa71143fe9969
  • Pointer size: 132 Bytes
  • Size of remote file: 4.73 MB
output-onnx.png ADDED

Git LFS Details

  • SHA256: dc0db36b8986d5d8e24666670d4b7f20098c40fed11378409db4167c12af0ac2
  • Pointer size: 132 Bytes
  • Size of remote file: 4.72 MB
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