qqc1989 commited on
Commit
163c901
·
verified ·
1 Parent(s): d6c8064

Delete python/python

Browse files
python/python/infer.py DELETED
@@ -1,50 +0,0 @@
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 DELETED
@@ -1,56 +0,0 @@
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 DELETED
@@ -1,3 +0,0 @@
1
- onnx
2
- onnxruntime
3
- opencv-python