Views
No views yet
| Model | Download | Download (with sample test data) | ONNX version | Opset version | Accuracy |
|---|---|---|---|---|---|
| YOLOv3 | 237 MB | 222 MB | 1.5 | 10 | mAP of 0.553 |
| YOLOv3-12 | 237 MB | 222 MB | 1.9 | 12 | mAP of 0.2874 |
| YOLOv3-12-int8 | 60 MB | 53 MB | 1.9 | 12 | mAP of 0.2693 |
Compared with the YOLOv3-12, YOLOv3-12-int8's mAP decline is 0.0181 and performance improvement is 2.19x.Note the performance depends on the test hardware.Performance data here is collected with Intel® Xeon® Platinum 8280 Processor, 1s 4c per instance, CentOS Linux 8.3, data batch size is 1.
(1x3x416x416)
Original image size (1x2) which is [image.size[1], image.size[0]]1import numpy as np
2from PIL import Image
3
4# this function is from yolo3.utils.letterbox_image
5def letterbox_image(image, size):
6'''resize image with unchanged aspect ratio using padding'''
7iw, ih = image.size
8w, h = size
9scale = min(w/iw, h/ih)
10nw = int(iw*scale)
11nh = int(ih*scale)
12
13image = image.resize((nw,nh), Image.BICUBIC)
14new_image = Image.new('RGB', size, (128,128,128))
15new_image.paste(image, ((w-nw)//2, (h-nh)//2))
16return new_image
17
18def preprocess(img):
19model_image_size = (416, 416)
20boxed_image = letterbox_image(img, tuple(reversed(model_image_size)))
21image_data = np.array(boxed_image, dtype='float32')
22image_data /= 255.
23image_data = np.transpose(image_data, [2, 0, 1])
24image_data = np.expand_dims(image_data, 0)
25return image_data
26
27image = Image.open(img_path)
28# input
29image_data = preprocess(image)
30image_size = np.array([image.size[1], image.size[0]], dtype=np.int32).reshape(1, 2)(1x'n_candidates'x4), the coordinates of all anchor boxes,
scores: (1x80x'n_candidates'), the scores of all anchor boxes per class,
indices: ('nbox'x3), selected indices from the boxes tensor. The selected index format is (batch_index, class_index, box_index). The class list is hereout_boxes, out_scores, out_classes = [], [], []
for idx_ in indices:
out_classes.append(idx_[1])
out_scores.append(scores[tuple(idx_)])
idx_1 = (idx_[0], idx_[2])
out_boxes.append(boxes[idx_1])wget https://github.com/onnx/models/raw/main/vision/object_detection_segmentation/yolov3/model/yolov3-12.onnx1bash run_tuning.sh --input_model=path/to/model \ # model path as *.onnx
2--config=yolov3.yaml \
3--data_path=path/to/COCO2017 \
4--output_model=path/to/save