KevinHsuWavematrix commited on
Commit
49c2c09
·
0 Parent(s):

First release

Browse files
.gitattributes ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
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
+ *.model filter=lfs diff=lfs merge=lfs -text
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
36
+ *.axmodel filter=lfs diff=lfs merge=lfs -text
37
+ ax_yolo11 filter=lfs diff=lfs merge=lfs -text
38
+ football.jpg filter=lfs diff=lfs merge=lfs -text
39
+ yolo11_out.jpg filter=lfs diff=lfs merge=lfs -text
40
+ ax_aarch64/ax_yolo11 filter=lfs diff=lfs merge=lfs -text
41
+ axcl_aarch64/axcl_yolo11 filter=lfs diff=lfs merge=lfs -text
42
+ axcl_x86_64/axcl_yolo11 filter=lfs diff=lfs merge=lfs -text
43
+ ssd_horse.jpg filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ base_model:
6
+ - Ultralytics/YOLO11
7
+ pipeline_tag: object-detection
8
+ tags:
9
+ - Ultralytics
10
+ - YOLO11
11
+ ---
12
+
13
+ # YOLO11
14
+
15
+ This version of YOLO11 has been converted to run on the WaveMatrix NPU using **w8a16** quantization.
16
+
17
+ This model has been optimized with the following LoRA:
18
+
19
+ Compatible with Pulsar2 version: 3.4
20
+
21
+ ## Convert tools links:
22
+
23
+ For those who are interested in model conversion, you can try to export axmodel through
24
+
25
+ - [The repo of ax-samples](https://github.com/WaveMatrix/ax-samples), which you can get the how to build the `ax_yolo11`
26
+
27
+ - [The repo of axcl-samples](https://github.com/WaveMatrix/axcl-samples), which you can get the how to build the `axcl_yolo11`
28
+
29
+ - [Pulsar2 Link, How to Convert ONNX to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/pulsar2/introduction.html)
30
+
31
+
32
+ ## Support Platform
33
+
34
+ - WM9955
35
+ - Demo board
36
+ - M.2 Accelerator card
37
+
38
+ |Chips|cost|
39
+ |--|--|
40
+ |WM9955| 25 ms |
41
+
42
+ ## How to use
43
+
44
+ Download all files from this repository to the device
45
+
46
+ ```
47
+ (axcl) wavematrix@raspberrypi:~/samples/WaveMatrix/YOLO11 $ tree -L 2
48
+ .
49
+ ├── wm9955
50
+ │   ├── yolo11s.axmodel
51
+ │   └── yolo11x.axmodel
52
+ ├── ax_aarch64
53
+ │   └── ax_yolo11
54
+ ├── axcl_aarch64
55
+ │   └── axcl_yolo11
56
+ ├── axcl_x86_64
57
+ │   └── axcl_yolo11
58
+ ├── config.json
59
+ ├── cut-onnx.py
60
+ ├── football.jpg
61
+ ├── README.md
62
+ ├── ssd_horse.jpg
63
+ ├── yolo11_config.json
64
+ ├── yolo11_out.jpg
65
+ ├── yolo11s-cut.onnx
66
+ └── yolo11-test.py
67
+
68
+ 6 directories, 15 files
69
+
70
+ ```
71
+
72
+ ### Inference
73
+
74
+ Input image:
75
+ ![](./football.jpg)
76
+
77
+ #### Inference with WM9955 Host, such as demo board
78
+
79
+ ```
80
+ root@wm9955:~/samples/WaveMatrix/YOLO11# ./ax_aarch64/ax_yolo11 -m wm9955/yolo11x.axmodel -i football.jpg
81
+ --------------------------------------
82
+ model file : wm9955/yolo11x.axmodel
83
+ image file : football.jpg
84
+ img_h, img_w : 640 640
85
+ --------------------------------------
86
+ Engine creating handle is done.
87
+ Engine creating context is done.
88
+ Engine get io info is done.
89
+ Engine alloc io is done.
90
+ Engine push input is done.
91
+ --------------------------------------
92
+ post process cost time:4.20 ms
93
+ --------------------------------------
94
+ Repeat 1 times, avg time 24.56 ms, max_time 24.56 ms, min_time 24.56 ms
95
+ --------------------------------------
96
+ detection num: 9
97
+ 0: 94%, [ 757, 220, 1127, 1154], person
98
+ 0: 94%, [ 0, 357, 314, 1112], person
99
+ 0: 93%, [1353, 339, 1629, 1037], person
100
+ 0: 91%, [ 494, 476, 659, 1001], person
101
+ 32: 86%, [1231, 877, 1281, 922], sports ball
102
+ 32: 73%, [ 774, 887, 828, 938], sports ball
103
+ 32: 66%, [1012, 882, 1051, 927], sports ball
104
+ 0: 54%, [ 0, 543, 83, 1000], person
105
+ 0: 46%, [1837, 696, 1877, 814], person
106
+ --------------------------------------
107
+ ```
108
+
109
+ Output image:
110
+ ![](./yolo11_out.jpg)
111
+
112
+
113
+ #### Inference with M.2 Accelerator card
114
+
115
+ ```
116
+ (axcl) wavematrix@raspberrypi:~/samples/WaveMatrix/YOLO11 $ ./axcl_aarch64/axcl_yolo11 -m wm9955/yolo11x.axmodel -i football.jpg
117
+ --------------------------------------
118
+ model file : wm9955/yolo11x.axmodel
119
+ image file : football.jpg
120
+ img_h, img_w : 640 640
121
+ --------------------------------------
122
+ axclrtEngineCreateContextt is done.
123
+ axclrtEngineGetIOInfo is done.
124
+
125
+ grpid: 0
126
+
127
+ input size: 1
128
+ name: images
129
+ 1 x 640 x 640 x 3
130
+
131
+
132
+ output size: 3
133
+ name: /model.23/Concat_output_0
134
+ 1 x 80 x 80 x 144
135
+
136
+ name: /model.23/Concat_1_output_0
137
+ 1 x 40 x 40 x 144
138
+
139
+ name: /model.23/Concat_2_output_0
140
+ 1 x 20 x 20 x 144
141
+
142
+ ==================================================
143
+
144
+ Engine push input is done.
145
+ --------------------------------------
146
+ post process cost time:1.38 ms
147
+ --------------------------------------
148
+ Repeat 1 times, avg time 24.73 ms, max_time 24.73 ms, min_time 24.73 ms
149
+ --------------------------------------
150
+ detection num: 9
151
+ 0: 94%, [ 757, 220, 1127, 1154], person
152
+ 0: 94%, [ 0, 357, 314, 1112], person
153
+ 0: 93%, [1353, 339, 1629, 1037], person
154
+ 0: 91%, [ 494, 476, 659, 1001], person
155
+ 32: 86%, [1231, 877, 1281, 922], sports ball
156
+ 32: 73%, [ 774, 887, 828, 938], sports ball
157
+ 32: 66%, [1012, 882, 1051, 927], sports ball
158
+ 0: 54%, [ 0, 543, 83, 1000], person
159
+ 0: 46%, [1837, 696, 1877, 814], person
160
+ --------------------------------------
161
+
162
+ ```
ax_aarch64/ax_yolo11 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2498cb336fc589eb89637b0a55b0b075d7a07632d5ae04977efdb5c44389129d
3
+ size 5466632
axcl_aarch64/axcl_yolo11 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4dd953dc7f1cd0def3332fc01ac891673d2c4ca4a36ff3d756c7dc8ab7e9572c
3
+ size 135168
axcl_x86_64/axcl_yolo11 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b94a71f04fd79c901a6b1ed75552be3d62ee162e9c3e2003656da634129a7479
3
+ size 158664
config.json ADDED
File without changes
cut-onnx.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import onnx
2
+
3
+ input_path = "yolo11s.onnx"
4
+ output_path = "yolo11s-cut.onnx"
5
+ input_names = ["images"]
6
+ output_names = ["/model.23/Concat_output_0", "/model.23/Concat_1_output_0", "/model.23/Concat_2_output_0"]
7
+
8
+ onnx.utils.extract_model(input_path, output_path, input_names, output_names)
football.jpg ADDED

Git LFS Details

  • SHA256: e7c4b752ef447bfec409888cea8709be15c01d0f6bf91bd16b7762deb90950dc
  • Pointer size: 131 Bytes
  • Size of remote file: 325 kB
ssd_horse.jpg ADDED

Git LFS Details

  • SHA256: ed22f6b4c8c33e50e391e089ede14e8fa9402c623b09dbcf010e804770698fbb
  • Pointer size: 131 Bytes
  • Size of remote file: 123 kB
wm9955/yolo11s.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bad83368e9d68ae9740e9bb72c34e6b8173635faca7eb366e5484f578fa10fa2
3
+ size 10491152
wm9955/yolo11x.axmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18e3cd31f8a04750480f5e9c2d98a2684a51c6b5596da2def971427841e65d8b
3
+ size 60111496
yolo11-test.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ultralytics import YOLO
2
+
3
+ # Load a model
4
+ model = YOLO("yolo11s.pt")
5
+ model.info()
6
+
7
+ # Use the model
8
+ results = model("./images/ssd_horse.jpg")
9
+
10
+ # Save the results
11
+ results[0].save("yolo11s-result.jpg")
12
+
13
+ # Export to onnx with simplify
14
+ model.export(format='onnx', simplify=True)
15
+
16
+
yolo11_axera.py ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import axengine as axe
2
+ import numpy as np
3
+ import cv2
4
+ import argparse
5
+ from dataclasses import dataclass
6
+
7
+ # COCO Class Names
8
+ COCO_CLASSES = [
9
+ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',
10
+ 'train', 'truck', 'boat', 'traffic light', 'fire hydrant',
11
+ 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog',
12
+ 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra',
13
+ 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie',
14
+ 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball',
15
+ 'kite', 'baseball bat', 'baseball glove', 'skateboard',
16
+ 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup',
17
+ 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
18
+ 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza',
19
+ 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed',
20
+ 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote',
21
+ 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster',
22
+ 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors',
23
+ 'teddy bear', 'hair drier', 'toothbrush'
24
+ ]
25
+
26
+ @dataclass
27
+ class Object:
28
+ bbox: list # [x0, y0, width, height]
29
+ label: int
30
+ prob: float
31
+
32
+ def sigmoid(x):
33
+ return 1 / (1 + np.exp(-x))
34
+
35
+ def softmax(x, axis=-1):
36
+ x = x - np.max(x, axis=axis, keepdims=True)
37
+ e_x = np.exp(x)
38
+ return e_x / np.sum(e_x, axis=axis, keepdims=True)
39
+
40
+ def decode_distributions(feat, reg_max=16):
41
+ prob = softmax(feat, axis=-1)
42
+ dis = np.sum(prob * np.arange(reg_max), axis=-1)
43
+ return dis
44
+
45
+ def preprocess(image_path, input_size):
46
+ image = cv2.imread(image_path)
47
+ if image is None:
48
+ raise FileNotFoundError(f"Unable to read image file: {image_path}")
49
+ original_shape = image.shape[:2]
50
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
51
+ resized_image = cv2.resize(image, input_size)
52
+ input_tensor = np.expand_dims(resized_image, axis=0).astype(np.uint8)
53
+ return input_tensor, original_shape, image
54
+
55
+ def postprocess(outputs, original_shape, input_size, confidence_threshold, nms_threshold, reg_max=16):
56
+ heads = [
57
+ {'output': outputs[0], 'grid_size': input_size[0] // 8, 'stride': 8},
58
+ {'output': outputs[1], 'grid_size': input_size[0] // 16, 'stride': 16},
59
+ {'output': outputs[2], 'grid_size': input_size[0] // 32, 'stride': 32}
60
+ ]
61
+ detections = []
62
+ num_classes = 80
63
+ bbox_channels = 4 * reg_max
64
+ class_channels = num_classes
65
+
66
+ for head in heads:
67
+ output = head['output']
68
+ batch_size, grid_h, grid_w, channels = output.shape
69
+ stride = head['stride']
70
+
71
+ bbox_part = output[:, :, :, :bbox_channels]
72
+ class_part = output[:, :, :, bbox_channels:]
73
+
74
+ bbox_part = bbox_part.reshape(batch_size, grid_h, grid_w, 4, reg_max)
75
+ bbox_part = bbox_part.reshape(grid_h * grid_w, 4, reg_max)
76
+ class_part = class_part.reshape(batch_size, grid_h * grid_w, class_channels)
77
+
78
+ for b in range(batch_size):
79
+ for i in range(grid_h * grid_w):
80
+ h = i // grid_w
81
+ w = i % grid_w
82
+ class_scores = class_part[b, i, :]
83
+ class_id = np.argmax(class_scores)
84
+ class_score = class_scores[class_id]
85
+ box_prob = sigmoid(class_score)
86
+ if box_prob < confidence_threshold:
87
+ continue
88
+ bbox = bbox_part[i, :, :]
89
+ dis_left = decode_distributions(bbox[0, :], reg_max)
90
+ dis_top = decode_distributions(bbox[1, :], reg_max)
91
+ dis_right = decode_distributions(bbox[2, :], reg_max)
92
+ dis_bottom = decode_distributions(bbox[3, :], reg_max)
93
+ pb_cx = (w + 0.5) * stride
94
+ pb_cy = (h + 0.5) * stride
95
+ x0 = pb_cx - dis_left * stride
96
+ y0 = pb_cy - dis_top * stride
97
+ x1 = pb_cx + dis_right * stride
98
+ y1 = pb_cy + dis_bottom * stride
99
+ scale_x = original_shape[1] / input_size[0]
100
+ scale_y = original_shape[0] / input_size[1]
101
+ x0 = np.clip(x0 * scale_x, 0, original_shape[1] - 1)
102
+ y0 = np.clip(y0 * scale_y, 0, original_shape[0] - 1)
103
+ x1 = np.clip(x1 * scale_x, 0, original_shape[1] - 1)
104
+ y1 = np.clip(y1 * scale_y, 0, original_shape[0] - 1)
105
+ width = x1 - x0
106
+ height = y1 - y0
107
+ detections.append(Object(
108
+ bbox=[float(x0), float(y0), float(width), float(height)],
109
+ label=int(class_id),
110
+ prob=float(box_prob)
111
+ ))
112
+
113
+ if len(detections) == 0:
114
+ return []
115
+ boxes = np.array([d.bbox for d in detections])
116
+ scores = np.array([d.prob for d in detections])
117
+ class_ids = np.array([d.label for d in detections])
118
+
119
+ final_detections = []
120
+ unique_classes = np.unique(class_ids)
121
+ for cls in unique_classes:
122
+ idxs = np.where(class_ids == cls)[0]
123
+ cls_boxes = boxes[idxs]
124
+ cls_scores = scores[idxs]
125
+ x1_cls = cls_boxes[:, 0]
126
+ y1_cls = cls_boxes[:, 1]
127
+ x2_cls = cls_boxes[:, 0] + cls_boxes[:, 2]
128
+ y2_cls = cls_boxes[:, 1] + cls_boxes[:, 3]
129
+ areas = (x2_cls - x1_cls) * (y2_cls - y1_cls)
130
+ order = cls_scores.argsort()[::-1]
131
+ keep = []
132
+ while order.size > 0:
133
+ i = order[0]
134
+ keep.append(i)
135
+ if order.size == 1:
136
+ break
137
+ xx1 = np.maximum(x1_cls[i], x1_cls[order[1:]])
138
+ yy1 = np.maximum(y1_cls[i], y1_cls[order[1:]])
139
+ xx2 = np.minimum(x2_cls[i], x2_cls[order[1:]])
140
+ yy2 = np.minimum(y2_cls[i], y2_cls[order[1:]])
141
+ w = np.maximum(0, xx2 - xx1)
142
+ h = np.maximum(0, yy2 - yy1)
143
+ intersection = w * h
144
+ iou = intersection / (areas[i] + areas[order[1:]] - intersection)
145
+ inds = np.where(iou <= nms_threshold)[0]
146
+ order = order[inds + 1]
147
+ for idx in keep:
148
+ final_detections.append(Object(
149
+ bbox=cls_boxes[idx].tolist(),
150
+ label=int(cls),
151
+ prob=float(cls_scores[idx])
152
+ ))
153
+ return final_detections
154
+
155
+ def main():
156
+ parser = argparse.ArgumentParser(description="YOLO11 AXEngine Inference")
157
+ parser.add_argument('--model', type=str, default='yolo11x.axmodel', help='Model path')
158
+ parser.add_argument('--image', type=str, default='dog.jpg', help='Image path')
159
+ parser.add_argument('--conf', type=float, default=0.45, help='Confidence threshold')
160
+ parser.add_argument('--nms', type=float, default=0.45, help='NMS threshold')
161
+ parser.add_argument('--size', type=int, nargs=2, default=[640, 640], help='Input size W H')
162
+ parser.add_argument('--regmax', type=int, default=16, help='DFL reg_max value')
163
+ args = parser.parse_args()
164
+
165
+ try:
166
+ input_tensor, original_shape, original_image = preprocess(args.image, tuple(args.size))
167
+ except FileNotFoundError as e:
168
+ print(e)
169
+ return
170
+
171
+ try:
172
+ session = axe.InferenceSession(args.model)
173
+ except Exception as e:
174
+ print(f"Error loading model: {e}")
175
+ return
176
+
177
+ input_name = session.get_inputs()[0].name
178
+ output_names = [output.name for output in session.get_outputs()]
179
+
180
+ try:
181
+ outputs = session.run(output_names, {input_name: input_tensor})
182
+ except Exception as e:
183
+ print(f"Error during inference: {e}")
184
+ return
185
+
186
+ try:
187
+ detections = postprocess(
188
+ outputs,
189
+ original_shape,
190
+ tuple(args.size),
191
+ args.conf,
192
+ args.nms,
193
+ reg_max=args.regmax
194
+ )
195
+ except Exception as e:
196
+ print(f"Error during post-processing: {e}")
197
+ return
198
+
199
+ for det in detections:
200
+ bbox = det.bbox
201
+ score = det.prob
202
+ class_id = det.label
203
+ if class_id >= len(COCO_CLASSES):
204
+ label = f"cls{class_id}: {score:.2f}"
205
+ else:
206
+ label = f"{COCO_CLASSES[class_id]}: {score:.2f}"
207
+ x, y, w, h = map(int, bbox)
208
+ cv2.rectangle(original_image, (x, y), (x + w, y + h), (0, 255, 0), 2)
209
+ cv2.putText(original_image, label, (x, y - 10),
210
+ cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
211
+
212
+ cv2.imwrite('detections.png', cv2.cvtColor(original_image, cv2.COLOR_RGB2BGR))
213
+ print("结果已保存到 detections.png")
214
+
215
+ if __name__ == '__main__':
216
+ main()
yolo11_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "ONNX",
3
+ "npu_mode": "NPU1",
4
+ "quant": {
5
+ "input_configs": [
6
+ {
7
+ "tensor_name": "images",
8
+ "calibration_dataset": "./dataset/coco_1000.tar",
9
+ "calibration_size": 32,
10
+ "calibration_mean": [0, 0, 0],
11
+ "calibration_std": [255.0, 255.0, 255.0]
12
+ }
13
+ ],
14
+ "calibration_method": "MinMax",
15
+ "precision_analysis": true,
16
+ "precision_analysis_method":"EndToEnd"
17
+ },
18
+ "input_processors": [
19
+ {
20
+ "tensor_name": "images",
21
+ "tensor_format": "BGR",
22
+ "src_format": "BGR",
23
+ "src_dtype": "U8",
24
+ "src_layout": "NHWC"
25
+ }
26
+ ],
27
+ "output_processors": [
28
+ {
29
+ "tensor_name": "/model.23/Concat_output_0",
30
+ "dst_perm": [0, 2, 3, 1]
31
+ }, {
32
+ "tensor_name": "/model.23/Concat_1_output_0",
33
+ "dst_perm": [0, 2, 3, 1]
34
+ }, {
35
+ "tensor_name": "/model.23/Concat_2_output_0",
36
+ "dst_perm": [0, 2, 3, 1]
37
+ }
38
+ ],
39
+ "compiler": {
40
+ "check": 2
41
+ }
42
+ }
yolo11_out.jpg ADDED

Git LFS Details

  • SHA256: 58e472ce2327ad8a702e818948f59dc36be5bed5fb716d0d7fe5ef145bd110d0
  • Pointer size: 131 Bytes
  • Size of remote file: 130 kB
yolo11s-cut.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd483e87031d8c7bd04aaf18e6a50cd71006c9b086d09df4eb3614cd6cab3bf0
3
+ size 37856530