Upload 23 files
Browse files- .gitattributes +19 -0
- python/examples/demo01.jpg +0 -0
- python/examples/demo02.jpg +0 -0
- python/examples/demo03.jpg +0 -0
- python/examples/demo04.jpg +0 -0
- python/examples/demo05.jpg +0 -0
- python/examples/demo06.jpg +0 -0
- python/examples/demo07.jpg +0 -0
- python/examples/demo08.jpg +0 -0
- python/examples/demo09.jpg +0 -0
- python/examples/demo10.jpg +0 -0
- python/examples/demo11.jpg +0 -0
- python/examples/demo12.jpg +0 -0
- python/examples/demo13.jpg +0 -0
- python/examples/demo14.jpg +0 -0
- python/examples/demo15.jpg +0 -0
- python/examples/demo16.jpg +0 -0
- python/examples/demo17.jpg +0 -0
- python/examples/demo18.jpg +0 -0
- python/examples/demo20.jpg +0 -0
- python/python/infer.py +50 -0
- python/python/infer_onnx.py +56 -0
- python/python/requirements.txt +3 -0
.gitattributes
CHANGED
|
@@ -37,3 +37,22 @@ depth_anything_v2_vits_ax620e.axmodel filter=lfs diff=lfs merge=lfs -text
|
|
| 37 |
depth_anything_v2_vits_ax650.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 38 |
python/examples/demo19.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
python/output.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
depth_anything_v2_vits_ax650.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 38 |
python/examples/demo19.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
python/output.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
python/examples/demo01.jpg filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
python/examples/demo02.jpg filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
python/examples/demo03.jpg filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
python/examples/demo04.jpg filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
python/examples/demo05.jpg filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
python/examples/demo06.jpg filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
python/examples/demo07.jpg filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
python/examples/demo08.jpg filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
python/examples/demo09.jpg filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
python/examples/demo10.jpg filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
python/examples/demo11.jpg filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
python/examples/demo12.jpg filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
python/examples/demo13.jpg filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
python/examples/demo14.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
python/examples/demo15.jpg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
python/examples/demo16.jpg filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
python/examples/demo17.jpg filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
python/examples/demo18.jpg filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
python/examples/demo20.jpg filter=lfs diff=lfs merge=lfs -text
|
python/examples/demo01.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo02.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo03.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo04.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo05.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo06.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo07.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo08.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo09.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo10.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo11.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo12.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo13.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo14.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo15.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo16.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo17.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo18.jpg
CHANGED
|
|
Git LFS Details
|
python/examples/demo20.jpg
CHANGED
|
|
Git LFS Details
|
python/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, (518,518))
|
| 29 |
+
image = image[None]
|
| 30 |
+
|
| 31 |
+
session = axe.InferenceSession(model)
|
| 32 |
+
|
| 33 |
+
depth = session.run(None, {"input": 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/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, (518,518) )
|
| 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, {"input": 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/python/requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
onnx
|
| 2 |
+
onnxruntime
|
| 3 |
+
opencv-python
|