Skip to content

Commit 396da86

Browse files
committed
style(himo): add lidar_dt in if-else for himo data read.
1 parent 9a154a4 commit 396da86

File tree

4 files changed

+48
-37
lines changed

4 files changed

+48
-37
lines changed

dataprocess/extract_av2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def process_logs(data_dir: Path, output_dir: Path, nproc: int):
312312

313313
def main(
314314
argo_dir: str = "/home/kin/data/av2",
315-
output_dir: str ="/home/kin/data/av2/preprocess",
315+
output_dir: str ="/home/kin/data/av2/h5py",
316316
av2_type: str = "sensor",
317317
data_mode: str = "val",
318318
mask_dir: str = "/home/kin/data/av2/3d_scene_flow",

src/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def __getitem__(self, index_):
347347
data_dict[f'gmh{i+1}'] = past_gm
348348
data_dict[f'poseh{i+1}'] = past_pose
349349

350-
for data_key in self.vis_name + ['ego_motion',
350+
for data_key in self.vis_name + ['ego_motion', 'lidar_dt',
351351
# ground truth information:
352352
'flow', 'flow_is_valid', 'flow_category_indices', 'flow_instance_id', 'dufo']:
353353
if data_key in f[key]:

tools/readh5.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

tools/readh5pkl.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""
2+
# Created: 2023-12-31 22:19
3+
# LastEdit: 2024-01-12 18:46
4+
# Copyright (C) 2023-now, RPL, KTH Royal Institute of Technology
5+
# Author: Qingwen Zhang (https://kin-zhang.github.io/)
6+
7+
# Description:
8+
# Quick Read the keys in an h5 file, print out their shapes and data types etc.
9+
10+
# Example Running:
11+
python tools/readh5pkl.py --file_path /home/kin/data/av2/h5py/sensor/test/0c6e62d7-bdfa-3061-8d3d-03b13aa21f68.h5
12+
"""
13+
14+
import os, pickle
15+
os.environ["OMP_NUM_THREADS"] = "1"
16+
import fire, time, h5py
17+
18+
def readfile(
19+
file_path: str = "/home/kin/data/av2/h5py/sensor/test/0c6e62d7-bdfa-3061-8d3d-03b13aa21f68.h5"
20+
):
21+
if file_path.endswith('.h5'):
22+
with h5py.File(file_path, 'r') as f:
23+
for cnt, k in enumerate(f.keys()):
24+
if cnt % 2 == 1:
25+
continue
26+
print(f"id: {cnt}; Key (TimeStamp): {k}")
27+
for sub_k in f[k].keys():
28+
print(f" Sub-Key: {sub_k}, Shape: {f[k][sub_k].shape}, Dtype: {f[k][sub_k].dtype}")
29+
if cnt >= 10:
30+
break
31+
print(f"\nTotal {len(f.keys())} timestamps in the file.")
32+
elif file_path.endswith('.pkl'):
33+
with open(file_path, 'rb') as f:
34+
data_index = pickle.load(f)
35+
for cnt, (scene_token, timestamp) in enumerate(data_index):
36+
if cnt % 2 == 1:
37+
continue
38+
print(f"id: {cnt}; Scene Token: {scene_token}, Timestamp: {timestamp}")
39+
if cnt >= 10:
40+
break
41+
print(f"\nTotal {len(data_index)} timestamps in the file.")
42+
43+
if __name__ == '__main__':
44+
start_time = time.time()
45+
fire.Fire(readfile)
46+
print(f"\nTime used: {(time.time() - start_time)/60:.2f} mins")

0 commit comments

Comments
 (0)