Skip to content

Commit 89d5016

Browse files
Update benchmark notebook so that it is compatible with the octreelib@v0.0.5
1 parent 3374af3 commit 89d5016

File tree

1 file changed

+45
-69
lines changed

1 file changed

+45
-69
lines changed

notebooks/benchmark.ipynb

Lines changed: 45 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,33 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 1,
13+
"execution_count": 5,
1414
"id": "d009f3b8-3f04-4aac-b10a-4a2e0a34836e",
15-
"metadata": {},
16-
"outputs": [
17-
{
18-
"name": "stdout",
19-
"output_type": "stream",
20-
"text": [
21-
"Jupyter environment detected. Enabling Open3D WebVisualizer.\n",
22-
"[Open3D INFO] WebRTC GUI backend enabled.\n",
23-
"[Open3D INFO] WebRTCWindowSystem: HTTP handshake server disabled.\n"
24-
]
15+
"metadata": {
16+
"ExecuteTime": {
17+
"end_time": "2023-12-20T14:25:22.551281Z",
18+
"start_time": "2023-12-20T14:25:21.002067Z"
2519
}
26-
],
20+
},
21+
"outputs": [],
2722
"source": [
2823
"import sys\n",
2924
"import mrob\n",
3025
"import time\n",
3126
"import os\n",
32-
"from octreelib.grid import Grid, GridConfig, VisualizationConfig\n",
33-
"from octreelib.octree import MultiPoseOctree, OctreeConfig\n",
34-
"from typing import Tuple, List\n",
27+
"import tqdm\n",
28+
"from octreelib.grid import Grid, GridConfig\n",
29+
"from typing import Tuple, List, Dict\n",
3530
"from dataclasses import dataclass\n",
3631
"import numpy as np\n",
3732
"import open3d as o3d\n",
3833
"\n",
3934
"sys.path.append(\"..\")\n",
4035
"from slam.backend import BaregBackend, EigenFactorBackend, Backend, BackendOutput\n",
41-
"from slam.pipeline import StaticPipeline, StaticPipelineRuntimeParameters\n",
36+
"\n",
4237
"from slam.segmenter import Segmenter, CAPESegmenter, RansacSegmenter\n",
4338
"from slam.subdivider import Subdivider, CountSubdivider, EigenValueSubdivider, SizeSubdivider\n",
44-
"from slam.utils import Reader, HiltiReader, KittiReader"
39+
"from slam.utils import DatasetReader, HiltiReader, KittiReader"
4540
]
4641
},
4742
{
@@ -54,9 +49,14 @@
5449
},
5550
{
5651
"cell_type": "code",
57-
"execution_count": 2,
52+
"execution_count": 6,
5853
"id": "4e183c65-5a53-4152-a1e0-9eeb8afc49de",
59-
"metadata": {},
54+
"metadata": {
55+
"ExecuteTime": {
56+
"end_time": "2023-12-20T14:25:23.389009Z",
57+
"start_time": "2023-12-20T14:25:23.384258Z"
58+
}
59+
},
6060
"outputs": [],
6161
"source": [
6262
"SAMPLES_COUNT = 10"
@@ -72,9 +72,14 @@
7272
},
7373
{
7474
"cell_type": "code",
75-
"execution_count": 3,
75+
"execution_count": 7,
7676
"id": "49fcabc0-83d2-4bdb-821e-4f5735930ca1",
77-
"metadata": {},
77+
"metadata": {
78+
"ExecuteTime": {
79+
"end_time": "2023-12-20T14:25:24.005440Z",
80+
"start_time": "2023-12-20T14:25:23.992233Z"
81+
}
82+
},
7883
"outputs": [],
7984
"source": [
8085
"def evaluate(timestamps: List[float]):\n",
@@ -90,7 +95,7 @@
9095
" timestamps = np.array(timestamps)\n",
9196
" print_metrics(timestamps)\n",
9297
"\n",
93-
"def read_patch(reader: Reader,path: str, start: int, end: int) -> List[o3d.geometry.PointCloud]:\n",
98+
"def read_patch(reader: DatasetReader,path: str, start: int, end: int) -> List[o3d.geometry.PointCloud]:\n",
9499
" \"\"\"\n",
95100
" Reads patch of point clouds\n",
96101
" \"\"\"\n",
@@ -121,9 +126,7 @@
121126
},
122127
{
123128
"cell_type": "code",
124-
"execution_count": 4,
125-
"id": "22088f09-504b-4221-a0df-8bd09ad2a15c",
126-
"metadata": {},
129+
"execution_count": 8,
127130
"outputs": [],
128131
"source": [
129132
"@dataclass\n",
@@ -147,7 +150,7 @@
147150
" distribution: float\n",
148151
" segmenters: float\n",
149152
" backend: float\n",
150-
"\n",
153+
" \n",
151154
"\n",
152155
"def run_pipeline(point_clouds: List[o3d.geometry.PointCloud], pipeline: PipelineConfiguration) -> PipelineDurations:\n",
153156
" \"\"\"\n",
@@ -159,7 +162,7 @@
159162
" initialization_start = time.perf_counter()\n",
160163
" pipeline.grid.insert_points(\n",
161164
" middle_pose_number,\n",
162-
" point_clouds[middle_pose_number].points,\n",
165+
" np.asarray(point_clouds[middle_pose_number].points),\n",
163166
" )\n",
164167
" initialization_end = time.perf_counter() - initialization_start\n",
165168
" \n",
@@ -171,7 +174,7 @@
171174
" for pose_number, point_cloud in enumerate(point_clouds):\n",
172175
" if pose_number == middle_pose_number:\n",
173176
" continue\n",
174-
" pipeline.grid.insert_points(pose_number, point_cloud.points)\n",
177+
" pipeline.grid.insert_points(pose_number, np.asarray(point_cloud.points))\n",
175178
" distribution_end = time.perf_counter() - distribution_start\n",
176179
"\n",
177180
" segmenters_start = time.perf_counter()\n",
@@ -190,7 +193,15 @@
190193
" segmenters=segmenters_end,\n",
191194
" backend=backend_end,\n",
192195
" )"
193-
]
196+
],
197+
"metadata": {
198+
"collapsed": false,
199+
"ExecuteTime": {
200+
"end_time": "2023-12-20T14:25:24.923503Z",
201+
"start_time": "2023-12-20T14:25:24.918673Z"
202+
}
203+
},
204+
"id": "1528c7c19e4d9cfe"
194205
},
195206
{
196207
"cell_type": "markdown",
@@ -202,43 +213,10 @@
202213
},
203214
{
204215
"cell_type": "code",
205-
"execution_count": 5,
206-
"id": "1156e0c8-d70d-4c12-a9ff-773ca383912b",
216+
"execution_count": null,
217+
"id": "1eed4317-fa5b-4980-8fae-58263c0b1cfd",
207218
"metadata": {},
208-
"outputs": [
209-
{
210-
"name": "stdout",
211-
"output_type": "stream",
212-
"text": [
213-
"Patch 0 -> 3; Samples count = 10\n",
214-
"First point clouds insertion stage\n",
215-
"\tmin = 2.647s\n",
216-
"\tmax = 2.863s\n",
217-
"\tmean = 2.708s\n",
218-
"\tstd = 0.066s\n",
219-
"Subdividers stage\n",
220-
"\tmin = 8.991s\n",
221-
"\tmax = 9.287s\n",
222-
"\tmean = 9.077s\n",
223-
"\tstd = 0.087s\n",
224-
"Distribution stage\n",
225-
"\tmin = 20.751s\n",
226-
"\tmax = 21.297s\n",
227-
"\tmean = 20.877s\n",
228-
"\tstd = 0.151s\n",
229-
"Segmenters stage\n",
230-
"\tmin = 7.337s\n",
231-
"\tmax = 9.898s\n",
232-
"\tmean = 7.762s\n",
233-
"\tstd = 0.769s\n",
234-
"Backend stage\n",
235-
"\tmin = 0.096s\n",
236-
"\tmax = 0.155s\n",
237-
"\tmean = 0.104s\n",
238-
"\tstd = 0.017s\n"
239-
]
240-
}
241-
],
219+
"outputs": [],
242220
"source": [
243221
"# Pipeline configuration\n",
244222
"# TODO(user): You can manipulate configuration spec below as you want\n",
@@ -274,9 +252,7 @@
274252
"\n",
275253
" grid = Grid(\n",
276254
" GridConfig(\n",
277-
" octree_type=MultiPoseOctree,\n",
278-
" octree_config=OctreeConfig(),\n",
279-
" grid_voxel_edge_length=4,\n",
255+
" voxel_edge_length=4,\n",
280256
" )\n",
281257
" )\n",
282258
" \n",
@@ -297,7 +273,7 @@
297273
" segmenters_timestamps = []\n",
298274
" backend_timestamps = []\n",
299275
" \n",
300-
" for sample in range(SAMPLES_COUNT):\n",
276+
" for sample in tqdm.tqdm(range(SAMPLES_COUNT)):\n",
301277
" point_clouds = read_patch(dataset_reader, dataset_path, ind, ind + step)\n",
302278
" \n",
303279
" pipeline_durations = run_pipeline(point_clouds, create_configuration())\n",

0 commit comments

Comments
 (0)