Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

benchmark.js 6.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
  1. // YOLO models chart ---------------------------------------------------------------------------------------------------
  2. const data = {
  3. YOLO11: {
  4. n: { speed: 1.55, mAP: 39.5 },
  5. s: { speed: 2.63, mAP: 47.0 },
  6. m: { speed: 5.27, mAP: 51.4 },
  7. l: { speed: 6.84, mAP: 53.2 },
  8. x: { speed: 12.49, mAP: 54.7 },
  9. },
  10. YOLOv10: {
  11. n: { speed: 1.56, mAP: 39.5 },
  12. s: { speed: 2.66, mAP: 46.7 },
  13. m: { speed: 5.48, mAP: 51.3 },
  14. b: { speed: 6.54, mAP: 52.7 },
  15. l: { speed: 8.33, mAP: 53.3 },
  16. x: { speed: 12.2, mAP: 54.4 },
  17. },
  18. YOLOv9: {
  19. t: { speed: 2.3, mAP: 37.8 },
  20. s: { speed: 3.54, mAP: 46.5 },
  21. m: { speed: 6.43, mAP: 51.5 },
  22. c: { speed: 7.16, mAP: 52.8 },
  23. e: { speed: 16.77, mAP: 55.1 },
  24. },
  25. YOLOv8: {
  26. n: { speed: 1.47, mAP: 37.3 },
  27. s: { speed: 2.66, mAP: 44.9 },
  28. m: { speed: 5.86, mAP: 50.2 },
  29. l: { speed: 9.06, mAP: 52.9 },
  30. x: { speed: 14.37, mAP: 53.9 },
  31. },
  32. YOLOv7: { l: { speed: 6.84, mAP: 51.4 }, x: { speed: 11.57, mAP: 53.1 } },
  33. "YOLOv6-3.0": {
  34. n: { speed: 1.17, mAP: 37.5 },
  35. s: { speed: 2.66, mAP: 45.0 },
  36. m: { speed: 5.28, mAP: 50.0 },
  37. l: { speed: 8.95, mAP: 52.8 },
  38. },
  39. YOLOv5: {
  40. s: { speed: 1.92, mAP: 37.4 },
  41. m: { speed: 4.03, mAP: 45.4 },
  42. l: { speed: 6.61, mAP: 49.0 },
  43. x: { speed: 11.89, mAP: 50.7 },
  44. },
  45. "PP-YOLOE+": {
  46. t: { speed: 2.84, mAP: 39.9 },
  47. s: { speed: 2.62, mAP: 43.7 },
  48. m: { speed: 5.56, mAP: 49.8 },
  49. l: { speed: 8.36, mAP: 52.9 },
  50. x: { speed: 14.3, mAP: 54.7 },
  51. },
  52. "DAMO-YOLO": {
  53. t: { speed: 2.32, mAP: 42.0 },
  54. s: { speed: 3.45, mAP: 46.0 },
  55. m: { speed: 5.09, mAP: 49.2 },
  56. l: { speed: 7.18, mAP: 50.8 },
  57. },
  58. YOLOX: {
  59. s: { speed: 2.56, mAP: 40.5 },
  60. m: { speed: 5.43, mAP: 46.9 },
  61. l: { speed: 9.04, mAP: 49.7 },
  62. x: { speed: 16.1, mAP: 51.1 },
  63. },
  64. RTDETRv2: {
  65. s: { speed: 5.03, mAP: 48.1 },
  66. m: { speed: 7.51, mAP: 51.9 },
  67. l: { speed: 9.76, mAP: 53.4 },
  68. x: { speed: 15.03, mAP: 54.3 },
  69. },
  70. };
  71. let chart = null; // chart variable will hold the reference to the current chart instance.
  72. // Function to lighten a hex color by a specified amount.
  73. function lightenHexColor(color, amount = 0.5) {
  74. const r = parseInt(color.slice(1, 3), 16);
  75. const g = parseInt(color.slice(3, 5), 16);
  76. const b = parseInt(color.slice(5, 7), 16);
  77. const newR = Math.min(255, Math.round(r + (255 - r) * amount));
  78. const newG = Math.min(255, Math.round(g + (255 - g) * amount));
  79. const newB = Math.min(255, Math.round(b + (255 - b) * amount));
  80. return `#${newR.toString(16).padStart(2, "0")}${newG.toString(16).padStart(2, "0")}${newB.toString(16).padStart(2, "0")}`;
  81. }
  82. // Function to update the benchmarks chart.
  83. function updateChart() {
  84. if (chart) {
  85. chart.destroy();
  86. } // If a chart instance already exists, destroy it.
  87. // Define a specific color map for models.
  88. const colorMap = {
  89. YOLO11: "#0b23a9",
  90. YOLOv10: "#ff7f0e",
  91. YOLOv9: "#2ca02c",
  92. YOLOv8: "#d62728",
  93. YOLOv7: "#9467bd",
  94. "YOLOv6-3.0": "#8c564b",
  95. YOLOv5: "#e377c2",
  96. "PP-YOLOE+": "#7f7f7f",
  97. "DAMO-YOLO": "#bcbd22",
  98. YOLOX: "#17becf",
  99. RTDETRv2: "#eccd22",
  100. };
  101. // Get the selected algorithms from the checkboxes.
  102. const selectedAlgorithms = [
  103. ...document.querySelectorAll('input[name="algorithm"]:checked'),
  104. ].map((e) => e.value);
  105. // Create the datasets for the selected algorithms.
  106. const datasets = selectedAlgorithms.map((algorithm, i) => {
  107. const baseColor =
  108. colorMap[algorithm] || `hsl(${Math.random() * 360}, 70%, 50%)`;
  109. const lineColor = i === 0 ? baseColor : lightenHexColor(baseColor, 0.6); // Lighten non-primary lines.
  110. return {
  111. label: algorithm, // Label for the data points in the legend.
  112. data: Object.entries(data[algorithm]).map(([version, point]) => ({
  113. x: point.speed, // Speed data points on the x-axis.
  114. y: point.mAP, // mAP data points on the y-axis.
  115. version: version.toUpperCase(), // Store the version as additional data.
  116. })),
  117. fill: false, // Don't fill the chart.
  118. borderColor: lineColor, // Use the lightened color for the line.
  119. tension: 0.3, // Smooth the line.
  120. pointRadius: i === 0 ? 7 : 4, // Highlight primary dataset points.
  121. pointHoverRadius: i === 0 ? 9 : 6, // Highlight hover for primary dataset.
  122. pointBackgroundColor: lineColor, // Fill points with the line color.
  123. pointBorderColor: "#ffffff", // Add a border around points for contrast.
  124. borderWidth: i === 0 ? 3 : 1.5, // Slightly increase line size for the primary dataset.
  125. };
  126. });
  127. if (datasets.length === 0) {
  128. return;
  129. } // If there are no selected algorithms, return without creating a new chart.
  130. // Create a new chart instance.
  131. chart = new Chart(document.getElementById("chart").getContext("2d"), {
  132. type: "line", // Set the chart type to line.
  133. data: { datasets },
  134. options: {
  135. plugins: {
  136. legend: {
  137. display: true,
  138. position: "top",
  139. labels: { color: "#808080" },
  140. }, // Configure the legend.
  141. tooltip: {
  142. callbacks: {
  143. label: (tooltipItem) => {
  144. const { dataset, dataIndex } = tooltipItem;
  145. const point = dataset.data[dataIndex];
  146. return `${dataset.label}${point.version.toLowerCase()}: Speed = ${point.x}, mAP = ${point.y}`; // Custom tooltip label.
  147. },
  148. },
  149. mode: "nearest",
  150. intersect: false,
  151. }, // Configure the tooltip.
  152. },
  153. interaction: { mode: "nearest", axis: "x", intersect: false }, // Configure the interaction mode.
  154. scales: {
  155. x: {
  156. type: "linear",
  157. position: "bottom",
  158. title: {
  159. display: true,
  160. text: "Latency T4 TensorRT10 FP16 (ms/img)",
  161. color: "#808080",
  162. }, // X-axis title.
  163. grid: { color: "#e0e0e0" }, // Grid line color.
  164. ticks: { color: "#808080" }, // Tick label color.
  165. },
  166. y: {
  167. title: { display: true, text: "mAP", color: "#808080" }, // Y-axis title.
  168. grid: { color: "#e0e0e0" }, // Grid line color.
  169. ticks: { color: "#808080" }, // Tick label color.
  170. },
  171. },
  172. },
  173. });
  174. }
  175. document$.subscribe(function () {
  176. function initializeApp() {
  177. if (typeof Chart !== "undefined") {
  178. document
  179. .querySelectorAll('input[name="algorithm"]')
  180. .forEach((checkbox) =>
  181. checkbox.addEventListener("change", updateChart),
  182. );
  183. updateChart();
  184. } else {
  185. setTimeout(initializeApp, 100); // Retry every 100ms
  186. }
  187. }
  188. initializeApp(); // Initial chart rendering
  189. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...