Wanli
commited on
Commit
·
a9286c4
1
Parent(s):
3cce3b2
beautify benchmark table (#157)
Browse files- README.md +1 -24
- benchmark/README.md +26 -0
- benchmark/color_table.svg +0 -0
- benchmark/generate_table.py +154 -0
- benchmark/requirements.txt +3 -2
README.md
CHANGED
@@ -21,30 +21,7 @@ Guidelines:
|
|
21 |
|
22 |
## Models & Benchmark Results
|
23 |
|
24 |
-
|
25 |
-
| ------------------------------------------------------- | ----------------------------- | ---------- | -------------- | ------------ | --------------- | ------------ | ------------------ | ----------- |
|
26 |
-
| [YuNet](./models/face_detection_yunet) | Face Detection | 160x120 | 0.72 | 5.43 | 12.18 | 4.04 | 2.24 | 86.69 |
|
27 |
-
| [SFace](./models/face_recognition_sface) | Face Recognition | 112x112 | 6.04 | 78.83 | 24.88 | 46.25 | 2.66 | --- |
|
28 |
-
| [FER](./models/facial_expression_recognition/) | Facial Expression Recognition | 112x112 | 3.16 | 32.53 | 31.07 | 29.80 | 2.19 | --- |
|
29 |
-
| [LPD-YuNet](./models/license_plate_detection_yunet/) | License Plate Detection | 320x240 | 8.63 | 167.70 | 56.12 | 29.53 | 7.63 | --- |
|
30 |
-
| [YOLOX](./models/object_detection_yolox/) | Object Detection | 640x640 | 141.20 | 1805.87 | 388.95 | 420.98 | 28.59 | --- |
|
31 |
-
| [NanoDet](./models/object_detection_nanodet/) | Object Detection | 416x416 | 66.03 | 225.10 | 64.94 | 116.64 | 20.62 | --- |
|
32 |
-
| [DB-IC15](./models/text_detection_db) (EN) | Text Detection | 640x480 | 71.03 | 1862.75 | 208.41 | --- | 17.15 | --- |
|
33 |
-
| [DB-TD500](./models/text_detection_db) (EN&CN) | Text Detection | 640x480 | 72.31 | 1878.45 | 210.51 | --- | 17.95 | --- |
|
34 |
-
| [CRNN-EN](./models/text_recognition_crnn) | Text Recognition | 100x32 | 20.16 | 278.11 | 196.15 | 125.30 | --- | --- |
|
35 |
-
| [CRNN-CN](./models/text_recognition_crnn) | Text Recognition | 100x32 | 23.07 | 297.48 | 239.76 | 166.79 | --- | --- |
|
36 |
-
| [PP-ResNet](./models/image_classification_ppresnet) | Image Classification | 224x224 | 34.71 | 463.93 | 98.64 | 75.45 | 6.99 | --- |
|
37 |
-
| [MobileNet-V1](./models/image_classification_mobilenet) | Image Classification | 224x224 | 5.90 | 72.33 | 33.18 | 145.66\* | 5.15 | --- |
|
38 |
-
| [MobileNet-V2](./models/image_classification_mobilenet) | Image Classification | 224x224 | 5.97 | 66.56 | 31.92 | 146.31\* | 5.41 | --- |
|
39 |
-
| [PP-HumanSeg](./models/human_segmentation_pphumanseg) | Human Segmentation | 192x192 | 8.81 | 73.13 | 67.97 | 74.77 | 6.94 | --- |
|
40 |
-
| [WeChatQRCode](./models/qrcode_wechatqrcode) | QR Code Detection and Parsing | 100x100 | 1.29 | 5.71 | --- | --- | --- | --- |
|
41 |
-
| [DaSiamRPN](./models/object_tracking_dasiamrpn) | Object Tracking | 1280x720 | 29.05 | 712.94 | 76.82 | --- | --- | --- |
|
42 |
-
| [YoutuReID](./models/person_reid_youtureid) | Person Re-Identification | 128x256 | 30.39 | 625.56 | 90.07 | 44.61 | 5.58 | --- |
|
43 |
-
| [MP-PalmDet](./models/palm_detection_mediapipe) | Palm Detection | 192x192 | 6.29 | 86.83 | 83.20 | 33.81 | 5.17 | --- |
|
44 |
-
| [MP-HandPose](./models/handpose_estimation_mediapipe) | Hand Pose Estimation | 224x224 | 4.68 | 43.57 | 40.10 | 19.47 | 6.27 | --- |
|
45 |
-
| [MP-PersonDet](./models/person_detection_mediapipe) | Person Detection | 224x224 | 13.88 | 98.52 | 56.69 | --- | 16.45 | --- |
|
46 |
-
|
47 |
-
\*: Models are quantized in per-channel mode, which run slower than per-tensor quantized models on NPU.
|
48 |
|
49 |
Hardware Setup:
|
50 |
|
|
|
21 |
|
22 |
## Models & Benchmark Results
|
23 |
|
24 |
+

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
Hardware Setup:
|
27 |
|
benchmark/README.md
CHANGED
@@ -57,6 +57,32 @@ python benchmark.py --all --cfg_overwrite_backend_target 1
|
|
57 |
|
58 |
Benchmark is done with latest `opencv-python==4.7.0.72` and `opencv-contrib-python==4.7.0.72` on the following platforms. Some models are excluded because of support issues.
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
### Intel 12700K
|
61 |
|
62 |
Specs: [details](https://www.intel.com/content/www/us/en/products/sku/134594/intel-core-i712700k-processor-25m-cache-up-to-5-00-ghz/specifications.html)
|
|
|
57 |
|
58 |
Benchmark is done with latest `opencv-python==4.7.0.72` and `opencv-contrib-python==4.7.0.72` on the following platforms. Some models are excluded because of support issues.
|
59 |
|
60 |
+
|
61 |
+
| Model | Task | Input Size | [CPU-INTEL (ms)](#intel-12700k) | [CPU-RPI (ms)](#rasberry-pi-4b) | [GPU-JETSON (ms)](#jetson-nano-b01) | [NPU-KV3 (ms)](#khadas-vim3) | [NPU-Ascend310 (ms)](#atlas-200-dk) | CPU-D1 (ms) |
|
62 |
+
|----------------------------------------------------------| ----------------------------- | ---------- |---------------------------------|---------------------------------|-------------------------------------|------------------------------|-------------------------------------|-------------|
|
63 |
+
| [YuNet](../models/face_detection_yunet) | Face Detection | 160x120 | 0.72 | 5.43 | 12.18 | 4.04 | 2.24 | 86.69 |
|
64 |
+
| [SFace](../models/face_recognition_sface) | Face Recognition | 112x112 | 6.04 | 78.83 | 24.88 | 46.25 | 2.66 | --- |
|
65 |
+
| [FER](../models/facial_expression_recognition/) | Facial Expression Recognition | 112x112 | 3.16 | 32.53 | 31.07 | 29.80 | 2.19 | --- |
|
66 |
+
| [LPD-YuNet](../models/license_plate_detection_yunet/) | License Plate Detection | 320x240 | 8.63 | 167.70 | 56.12 | 29.53 | 7.63 | --- |
|
67 |
+
| [YOLOX](../models/object_detection_yolox/) | Object Detection | 640x640 | 141.20 | 1805.87 | 388.95 | 420.98 | 28.59 | --- |
|
68 |
+
| [NanoDet](../models/object_detection_nanodet/) | Object Detection | 416x416 | 66.03 | 225.10 | 64.94 | 116.64 | 20.62 | --- |
|
69 |
+
| [DB-IC15](../models/text_detection_db) (EN) | Text Detection | 640x480 | 71.03 | 1862.75 | 208.41 | --- | 17.15 | --- |
|
70 |
+
| [DB-TD500](../models/text_detection_db) (EN&CN) | Text Detection | 640x480 | 72.31 | 1878.45 | 210.51 | --- | 17.95 | --- |
|
71 |
+
| [CRNN-EN](../models/text_recognition_crnn) | Text Recognition | 100x32 | 20.16 | 278.11 | 196.15 | 125.30 | --- | --- |
|
72 |
+
| [CRNN-CN](../models/text_recognition_crnn) | Text Recognition | 100x32 | 23.07 | 297.48 | 239.76 | 166.79 | --- | --- |
|
73 |
+
| [PP-ResNet](../models/image_classification_ppresnet) | Image Classification | 224x224 | 34.71 | 463.93 | 98.64 | 75.45 | 6.99 | --- |
|
74 |
+
| [MobileNet-V1](../models/image_classification_mobilenet) | Image Classification | 224x224 | 5.90 | 72.33 | 33.18 | 145.66\* | 5.15 | --- |
|
75 |
+
| [MobileNet-V2](../models/image_classification_mobilenet) | Image Classification | 224x224 | 5.97 | 66.56 | 31.92 | 146.31\* | 5.41 | --- |
|
76 |
+
| [PP-HumanSeg](../models/human_segmentation_pphumanseg) | Human Segmentation | 192x192 | 8.81 | 73.13 | 67.97 | 74.77 | 6.94 | --- |
|
77 |
+
| [WeChatQRCode](../models/qrcode_wechatqrcode) | QR Code Detection and Parsing | 100x100 | 1.29 | 5.71 | --- | --- | --- | --- |
|
78 |
+
| [DaSiamRPN](../models/object_tracking_dasiamrpn) | Object Tracking | 1280x720 | 29.05 | 712.94 | 76.82 | --- | --- | --- |
|
79 |
+
| [YoutuReID](../models/person_reid_youtureid) | Person Re-Identification | 128x256 | 30.39 | 625.56 | 90.07 | 44.61 | 5.58 | --- |
|
80 |
+
| [MP-PalmDet](../models/palm_detection_mediapipe) | Palm Detection | 192x192 | 6.29 | 86.83 | 83.20 | 33.81 | 5.17 | --- |
|
81 |
+
| [MP-HandPose](../models/handpose_estimation_mediapipe) | Hand Pose Estimation | 224x224 | 4.68 | 43.57 | 40.10 | 19.47 | 6.27 | --- |
|
82 |
+
| [MP-PersonDet](./models/person_detection_mediapipe) | Person Detection | 224x224 | 13.88 | 98.52 | 56.69 | --- | 16.45 | --- |
|
83 |
+
|
84 |
+
\*: Models are quantized in per-channel mode, which run slower than per-tensor quantized models on NPU.
|
85 |
+
|
86 |
### Intel 12700K
|
87 |
|
88 |
Specs: [details](https://www.intel.com/content/www/us/en/products/sku/134594/intel-core-i712700k-processor-25m-cache-up-to-5-00-ghz/specifications.html)
|
benchmark/color_table.svg
ADDED
|
benchmark/generate_table.py
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
import matplotlib as mpl
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
mpl.use("svg")
|
7 |
+
|
8 |
+
# parse a '.md' file and find a table. return table information
|
9 |
+
def parse_table(filepath):
|
10 |
+
with open(filepath, "r", encoding="utf-8") as f:
|
11 |
+
content = f.read()
|
12 |
+
lines = content.split("\n")
|
13 |
+
|
14 |
+
header = []
|
15 |
+
body = []
|
16 |
+
|
17 |
+
found_start = False # if found table start line
|
18 |
+
parse_done = False # if parse table done
|
19 |
+
for l in lines:
|
20 |
+
if found_start and parse_done:
|
21 |
+
break
|
22 |
+
l = l.strip()
|
23 |
+
if not l:
|
24 |
+
continue
|
25 |
+
if l.startswith("|") and l.endswith("|"):
|
26 |
+
if not found_start:
|
27 |
+
found_start = True
|
28 |
+
row = [c.strip() for c in l.split("|") if c.strip()]
|
29 |
+
if not header:
|
30 |
+
header = row
|
31 |
+
else:
|
32 |
+
body.append(row)
|
33 |
+
elif found_start:
|
34 |
+
parse_done = True
|
35 |
+
return header, body
|
36 |
+
|
37 |
+
|
38 |
+
# parse models information
|
39 |
+
def parse_data(models_info):
|
40 |
+
min_list = []
|
41 |
+
max_list = []
|
42 |
+
colors = []
|
43 |
+
for model in models_info:
|
44 |
+
# remove \*
|
45 |
+
data = [x.replace("\\*", "") for x in model]
|
46 |
+
# get max data
|
47 |
+
max_data = -1
|
48 |
+
max_idx = -1
|
49 |
+
min_data = 9999999
|
50 |
+
min_idx = -1
|
51 |
+
|
52 |
+
for i in range(len(data)):
|
53 |
+
try:
|
54 |
+
d = float(data[i])
|
55 |
+
if d > max_data:
|
56 |
+
max_data = d
|
57 |
+
max_idx = i
|
58 |
+
if d < min_data:
|
59 |
+
min_data = d
|
60 |
+
min_idx = i
|
61 |
+
except:
|
62 |
+
pass
|
63 |
+
|
64 |
+
min_list.append(min_idx)
|
65 |
+
max_list.append(max_idx)
|
66 |
+
|
67 |
+
# calculate colors
|
68 |
+
color = []
|
69 |
+
for t in data:
|
70 |
+
try:
|
71 |
+
t = (float(t) - min_data) / (max_data - min_data)
|
72 |
+
color.append(cmap(t))
|
73 |
+
except:
|
74 |
+
color.append('white')
|
75 |
+
colors.append(color)
|
76 |
+
return colors, min_list, max_list
|
77 |
+
|
78 |
+
|
79 |
+
if __name__ == '__main__':
|
80 |
+
hardware_info, models_info = parse_table("./README.md")
|
81 |
+
cmap = mpl.colormaps.get_cmap("RdYlGn_r")
|
82 |
+
# remove empty line
|
83 |
+
models_info.pop(0)
|
84 |
+
# remove reference
|
85 |
+
hardware_info = [re.sub(r'\[(.+?)]\(.+?\)', r'\1', r) for r in hardware_info]
|
86 |
+
models_info = [[re.sub(r'\[(.+?)]\(.+?\)', r'\1', c) for c in r] for r in models_info]
|
87 |
+
|
88 |
+
table_colors, min_list, max_list = parse_data(models_info)
|
89 |
+
table_texts = [hardware_info] + models_info
|
90 |
+
table_colors = [['white'] * len(hardware_info)] + table_colors
|
91 |
+
# create a color bar. base width set to 1000, color map height set to 80
|
92 |
+
fig, axs = plt.subplots(nrows=3, figsize=(10, 0.8))
|
93 |
+
gradient = np.linspace(0, 1, 256)
|
94 |
+
gradient = np.vstack((gradient, gradient))
|
95 |
+
axs[0].imshow(gradient, aspect='auto', cmap=cmap)
|
96 |
+
axs[0].text(-0.01, 0.5, "Faster", va='center', ha='right', fontsize=11, transform=axs[0].transAxes)
|
97 |
+
axs[0].text(1.01, 0.5, "Slower", va='center', ha='left', fontsize=11, transform=axs[0].transAxes)
|
98 |
+
|
99 |
+
# initialize a table
|
100 |
+
table = axs[1].table(cellText=table_texts,
|
101 |
+
cellColours=table_colors,
|
102 |
+
cellLoc="left",
|
103 |
+
loc="upper left")
|
104 |
+
|
105 |
+
# adjust table position
|
106 |
+
table_pos = axs[1].get_position()
|
107 |
+
axs[1].set_position([
|
108 |
+
table_pos.x0,
|
109 |
+
table_pos.y0 - table_pos.height,
|
110 |
+
table_pos.width,
|
111 |
+
table_pos.height
|
112 |
+
])
|
113 |
+
|
114 |
+
table.set_fontsize(11)
|
115 |
+
table.auto_set_font_size(False)
|
116 |
+
table.scale(1, 2)
|
117 |
+
table.auto_set_column_width(list(range(len(table_texts[0]))))
|
118 |
+
table.AXESPAD = 0 # cancel padding
|
119 |
+
|
120 |
+
# highlight the best number
|
121 |
+
for i in range(len(min_list)):
|
122 |
+
cell = table.get_celld()[(i + 1, min_list[i])]
|
123 |
+
cell.set_text_props(weight='bold', color='white')
|
124 |
+
|
125 |
+
table_height = 0
|
126 |
+
table_width = 0
|
127 |
+
# calculate table height and width
|
128 |
+
for i in range(len(table_texts)):
|
129 |
+
cell = table.get_celld()[(i, 0)]
|
130 |
+
table_height += cell.get_height()
|
131 |
+
for i in range(len(table_texts[0])):
|
132 |
+
cell = table.get_celld()[(0, i)]
|
133 |
+
table_width += cell.get_width() + 0.1
|
134 |
+
|
135 |
+
# add notes for table
|
136 |
+
axs[2].text(0, -table_height - 0.8, "\*: Models are quantized in per-channel mode, which run slower than per-tensor quantized models on NPU.", va='bottom', ha='left', fontsize=11, transform=axs[1].transAxes)
|
137 |
+
|
138 |
+
# turn off labels
|
139 |
+
for ax in axs:
|
140 |
+
ax.set_axis_off()
|
141 |
+
ax.set_xticks([])
|
142 |
+
ax.set_yticks([])
|
143 |
+
|
144 |
+
# adjust color map position to center
|
145 |
+
cm_pos = axs[0].get_position()
|
146 |
+
axs[0].set_position([
|
147 |
+
(table_width - 1) / 2,
|
148 |
+
cm_pos.y0,
|
149 |
+
cm_pos.width,
|
150 |
+
cm_pos.height
|
151 |
+
])
|
152 |
+
|
153 |
+
plt.rcParams['svg.fonttype'] = 'none'
|
154 |
+
plt.savefig("./color_table.svg", format='svg', bbox_inches="tight", pad_inches=0, metadata={'Date': None, 'Creator': None})
|
benchmark/requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
numpy
|
2 |
-
opencv-python
|
3 |
pyyaml
|
4 |
-
requests
|
|
|
|
1 |
numpy
|
2 |
+
opencv-python<5.0
|
3 |
pyyaml
|
4 |
+
requests
|
5 |
+
matplotlib>=3.7.1
|