Views
No views yet
| Model | Download | Download (with sample test data) | ONNX version | Opset version | Accuracy |
|---|---|---|---|---|---|
| Faster R-CNN R-50-FPN | 167.3 MB | 158.0 MB | 1.5 | 10 | mAP of 0.35 |
| Faster R-CNN R-50-FPN-fp32 | 168.5 MB | 156.2 MB | 1.9 | 12 | mAP of 0.3437 |
| Faster R-CNN R-50-FPN-int8 | 42.6 MB | 36.2 MB | 1.9 | 12 | mAP of 0.3409 |
| Faster R-CNN R-50-FPN-qdq | 43 MB | 29 MB | 1.9 | 12 | mAP of 0.3390 |
Compared with the fp32 FasterRCNN-12, int8 FasterRCNN-12's mAP decline ratio is 0.81% and performance improvement is 1.43x.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.
(3x'height'x'width')1import numpy as np
2from PIL import Image
3
4def preprocess(image):
5# Resize
6ratio = 800.0 / min(image.size[0], image.size[1])
7image = image.resize((int(ratio * image.size[0]), int(ratio * image.size[1])), Image.BILINEAR)
8
9# Convert to BGR
10image = np.array(image)[:, :, [2, 1, 0]].astype('float32')
11
12# HWC -> CHW
13image = np.transpose(image, [2, 0, 1])
14
15# Normalize
16mean_vec = np.array([102.9801, 115.9465, 122.7717])
17for i in range(image.shape[0]):
18image[i, :, :] = image[i, :, :] - mean_vec[i]
19
20# Pad to be divisible of 32
21import math
22padded_h = int(math.ceil(image.shape[1] / 32) * 32)
23padded_w = int(math.ceil(image.shape[2] / 32) * 32)
24
25padded_image = np.zeros((3, padded_h, padded_w), dtype=np.float32)
26padded_image[:, :image.shape[1], :image.shape[2]] = image
27image = padded_image
28
29return image
30
31img = Image.open('dependencies/demo.jpg')
32img_data = preprocess(img)('nbox'x4), in (xmin, ymin, xmax, ymax).('nbox').('nbox').1import matplotlib.pyplot as plt
2import matplotlib.patches as patches
3
4classes = [line.rstrip('\n') for line in open('coco_classes.txt')]
5
6def display_objdetect_image(image, boxes, labels, scores, score_threshold=0.7):
7# Resize boxes
8ratio = 800.0 / min(image.size[0], image.size[1])
9boxes /= ratio
10
11_, ax = plt.subplots(1, figsize=(12,9))
12image = np.array(image)
13ax.imshow(image)
14
15# Showing boxes with score > 0.7
16for box, label, score in zip(boxes, labels, scores):
17if score > score_threshold:
18rect = patches.Rectangle((box[0], box[1]), box[2] - box[0], box[3] - box[1], linewidth=1, edgecolor='b', facecolor='none')
19ax.annotate(classes[label] + ':' + str(np.round(score, 2)), (box[0], box[1]), color='w', fontsize=12)
20ax.add_patch(rect)
21plt.show()
22
23display_objdetect_image(img, boxes, labels, scores)coco_2014_minival dataset from COCO, which is exactly equivalent to the coco_2017_val dataset.wget https://github.com/onnx/models/raw/main/vision/object_detection_segmentation/faster-rcnn/model/FasterRCNN-12.onnx1bash run_tuning.sh --input_model=path/to/model \ # model path as *.onnx
2--config=faster_rcnn.yaml \
3--data_path=path/to/COCO2017 \
4--output_model=path/to/save