Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support PGD and multi-view FCOS3D++ on Waymo #2835

Merged
merged 41 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b10c39a
support training dsvt
JingweiZhang12 Jun 20, 2023
b00d3fe
Merge remote-tracking branch 'jingwei/dsvt_train' into dsvt_train
sunjiahao1999 Jul 12, 2023
7fecc0f
fix batch_size
sunjiahao1999 Aug 9, 2023
232c3b8
chage cam to lidar
Aug 10, 2023
a81529e
add cam instances
Aug 14, 2023
84d9fc7
add cam_instances
sunjiahao1999 Aug 16, 2023
b7b3b62
add description for skip
sunjiahao1999 Aug 16, 2023
1995b5a
fix num_ins_per_cat
Aug 18, 2023
a9c7cd3
refactor waymo create
sunjiahao1999 Aug 21, 2023
257bcb3
fix waymo create
sunjiahao1999 Aug 23, 2023
53620aa
remove some function not use
sunjiahao1999 Aug 24, 2023
061d9e6
fix cam_instances after refactor
sunjiahao1999 Aug 24, 2023
3c7d4e9
remove unused .py
sunjiahao1999 Aug 24, 2023
38e47b1
add fast eval
sunjiahao1999 Aug 28, 2023
8c6e8c0
add prallel eval
sunjiahao1999 Aug 29, 2023
eadd6fc
fail use parallel
sunjiahao1999 Aug 30, 2023
1705540
remove unused code
sunjiahao1999 Aug 30, 2023
76c9b6f
Merge from waymo_speed
sunjiahao1999 Sep 4, 2023
180d6df
fix create gt database bug
sunjiahao1999 Sep 11, 2023
8342685
fix train iter
sunjiahao1999 Sep 12, 2023
2c9b333
fix dis aug and model init
sunjiahao1999 Sep 15, 2023
9824778
train align
sunjiahao1999 Sep 18, 2023
681423f
fix lint
sunjiahao1999 Sep 18, 2023
fd0825a
fix basepoints in_range_3d
sunjiahao1999 Sep 18, 2023
13affc6
fix idx_all and add description
sunjiahao1999 Sep 18, 2023
e8166b3
Merge branch 'dev-1.x' into waymo_speed
sunjiahao1999 Sep 18, 2023
73b33c6
fix defualt pipeline
sunjiahao1999 Sep 18, 2023
fd2448a
10.27 Merge branch 'dev-1.x' into waymo_speed
sunjiahao1999 Oct 27, 2023
651dbf1
fix pgd fov
sunjiahao1999 Nov 20, 2023
bfb10b6
add mvfcos3d
sunjiahao1999 Dec 4, 2023
943d0ff
merge dsvt
sunjiahao1999 Dec 5, 2023
80a7a77
merge dev-1.x
sunjiahao1999 Dec 27, 2023
d714153
fix pgd config
sunjiahao1999 Dec 28, 2023
43963f8
fix mvfoc3d config && add doc
sunjiahao1999 Dec 28, 2023
3ea3f9f
merge dev-1.x
sunjiahao1999 Dec 28, 2023
6c00213
fix lint & delete unused
sunjiahao1999 Dec 28, 2023
31a59df
del unused
sunjiahao1999 Dec 28, 2023
0ecf88c
resolve comments
sunjiahao1999 Jan 4, 2024
ab31f64
del unused in pgd head
sunjiahao1999 Jan 4, 2024
5ff1df8
fix config comments bug and update waymo infos & mini link
sunjiahao1999 Jan 4, 2024
be43c4d
fix doc
sunjiahao1999 Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add cam_instances
  • Loading branch information
sunjiahao1999 committed Aug 16, 2023
commit 84d9fc787ec35bba9e2bb6b77d1540569bdd74f6
24 changes: 24 additions & 0 deletions check_coor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import mmengine
import numpy as np

from mmdet3d.structures import (Box3DMode, CameraInstance3DBoxes,
LiDARInstance3DBoxes)

val_infos = mmengine.load('data/waymo_mini/kitti_format/waymo_infos_val.pkl')
old_val_infos = mmengine.load(
'data/waymo_mini/kitti_format/old_pkl/waymo_infos_val.pkl')
instance = np.array(
val_infos['data_list'][0]['cam_sync_instances'][0]['bbox_3d'])[np.newaxis,
...]
instance = LiDARInstance3DBoxes(instance)
lidar2cam = np.array(
val_infos['data_list'][0]['images']['CAM_FRONT']['lidar2cam'])
cam_instance = instance.convert_to(Box3DMode.CAM, lidar2cam)

old_instance = np.array(old_val_infos['data_list'][0]['cam_sync_instances'][0]
['bbox_3d'])[np.newaxis, ...]

old_lidar2cam = np.array(
old_val_infos['data_list'][0]['images']['CAM_FRONT']['lidar2cam'])
old_instance = CameraInstance3DBoxes(old_instance)
pass
11 changes: 11 additions & 0 deletions get_gt_mini.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from waymo_open_dataset.protos.metrics_pb2 import Objects

objects = Objects()
with open('./data/waymo_mini/waymo_format/gt.bin', 'rb') as f:
objects.ParseFromString(bytearray(f.read()))
new = Objects()
for obj in objects.objects:
if obj.context_name == '10203656353524179475_7625_000_7645_000':
new.objects.append(obj)
with open('./data/waymo_mini/waymo_format/gt_mini.bin', 'wb') as f:
f.write(new.SerializeToString())
8 changes: 6 additions & 2 deletions mmdet3d/datasets/convert_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ def convert_annos(info: dict, cam_idx: int) -> dict:
"""Convert front-cam anns to i-th camera (KITTI-style info)."""
rect = info['calib']['R0_rect'].astype(np.float32)
# lidar2cam0 = info['calib']['Tr_velo_to_cam'].astype(np.float32)
lidar2cami = info['calib'][f'Tr_velo_to_cam{cam_idx}'].astype(np.float32)
if cam_idx == 0:
lidar2cami = info['calib']['Tr_velo_to_cam'].astype(np.float32)
else:
lidar2cami = info['calib'][f'Tr_velo_to_cam{cam_idx}'].astype(
np.float32)
annos = info['annos']
converted_annos = copy.deepcopy(annos)
loc = annos['location']
Expand All @@ -336,7 +340,7 @@ def convert_annos(info: dict, cam_idx: int) -> dict:
# gt_bboxes_3d = gt_bboxes_3d.convert_to(
# Box3DMode.CAM, rect @ lidar2cami, correct_yaw=True).numpy()
gt_bboxes_3d = LiDARInstance3DBoxes(gt_bboxes_3d).convert_to(
Box3DMode.CAM, rect @ lidar2cami, correct_yaw=True)
Box3DMode.CAM, rect @ lidar2cami, correct_yaw=True).numpy()

converted_annos['location'] = gt_bboxes_3d[:, :3]
converted_annos['dimensions'] = gt_bboxes_3d[:, 3:6]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
voxel_size = [0.32, 0.32, 6]
grid_size = [468, 468, 1]
point_cloud_range = [-74.88, -74.88, -2, 74.88, 74.88, 4.0]
# data_root = 'data/waymo_mini/kitti_format/'
data_root = 'data/waymo/kitti_format/'
data_root = 'data/waymo_mini/kitti_format/'
# data_root = 'data/waymo/kitti_format/'
class_names = ['Car', 'Pedestrian', 'Cyclist']
metainfo = dict(classes=class_names)
input_modality = dict(use_lidar=True, use_camera=False)
Expand Down Expand Up @@ -193,7 +193,7 @@

dataset_type = 'WaymoDataset'
val_dataloader = dict(
batch_size=4,
batch_size=1,
num_workers=4,
persistent_workers=True,
drop_last=False,
Expand All @@ -211,22 +211,22 @@
backend_args=backend_args))
test_dataloader = val_dataloader

# val_evaluator = dict(
# type='WaymoMetric',
# ann_file='./data/waymo_mini/kitti_format/waymo_infos_val.pkl',
# waymo_bin_file='./data/waymo_mini/waymo_format/gt_mini.bin',
# data_root='./data/waymo_mini/waymo_format',
# backend_args=backend_args,
# convert_kitti_format=False,
# idx2metainfo='./data/waymo_mini/waymo_format/idx2metainfo.pkl')
val_evaluator = dict(
type='WaymoMetric',
ann_file='./data/waymo/kitti_format/waymo_infos_val.pkl',
waymo_bin_file='./data/waymo/waymo_format/gt.bin',
data_root='./data/waymo/waymo_format',
ann_file='./data/waymo_mini/kitti_format/waymo_infos_val.pkl',
waymo_bin_file='./data/waymo_mini/waymo_format/gt_mini.bin',
data_root='./data/waymo_mini/waymo_format',
backend_args=backend_args,
convert_kitti_format=False,
idx2metainfo='./data/waymo/waymo_format/idx2metainfo.pkl')
idx2metainfo='./data/waymo_mini/waymo_format/idx2metainfo.pkl')
# val_evaluator = dict(
# type='WaymoMetric',
# ann_file='./data/waymo/kitti_format/waymo_infos_val.pkl',
# waymo_bin_file='./data/waymo/waymo_format/gt.bin',
# data_root='./data/waymo/waymo_format',
# backend_args=backend_args,
# convert_kitti_format=False,
# idx2metainfo='./data/waymo/waymo_format/idx2metainfo.pkl')
test_evaluator = val_evaluator

vis_backends = [dict(type='LocalVisBackend')]
Expand Down
35 changes: 24 additions & 11 deletions tools/create_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def waymo_data_prep(root_path,
version,
out_dir,
workers,
max_sweeps=5):
max_sweeps=10):
"""Prepare the info file for waymo dataset.

Args:
Expand Down Expand Up @@ -275,11 +275,16 @@ def semantickitti_data_prep(info_prefix, out_dir):
'--only-gt-database',
action='store_true',
help='Whether to only generate ground truth database.')
parser.add_argument(
'--skip-extract-kitti-format',
action='store_true',
help='''Whether to skip extracting kitti format image and point cloud.
Only used when dataset is waymo!''')
args = parser.parse_args()

if __name__ == '__main__':
from mmdet3d.utils import register_all_modules
register_all_modules()
from mmengine.registry import init_default_scope
init_default_scope('mmdet3d')

if args.dataset == 'kitti':
if args.only_gt_database:
Expand Down Expand Up @@ -334,6 +339,22 @@ def semantickitti_data_prep(info_prefix, out_dir):
dataset_name='NuScenesDataset',
out_dir=args.out_dir,
max_sweeps=args.max_sweeps)
elif args.dataset == 'waymo' and args.version == 'v1.4':
waymo_data_prep(
root_path=args.root_path,
info_prefix=args.extra_tag,
version=args.version,
out_dir=args.out_dir,
workers=args.workers,
max_sweeps=args.max_sweeps)
elif args.dataset == 'waymo' and args.version == 'v1.4-mini':
waymo_data_prep(
root_path=args.root_path,
info_prefix=args.extra_tag,
version=args.version,
out_dir=args.out_dir,
workers=args.workers,
max_sweeps=args.max_sweeps)
elif args.dataset == 'lyft':
train_version = f'{args.version}-train'
lyft_data_prep(
Expand All @@ -347,14 +368,6 @@ def semantickitti_data_prep(info_prefix, out_dir):
info_prefix=args.extra_tag,
version=test_version,
max_sweeps=args.max_sweeps)
elif args.dataset == 'waymo':
waymo_data_prep(
root_path=args.root_path,
info_prefix=args.extra_tag,
version=args.version,
out_dir=args.out_dir,
workers=args.workers,
max_sweeps=args.max_sweeps)
elif args.dataset == 'scannet':
scannet_data_prep(
root_path=args.root_path,
Expand Down
22 changes: 13 additions & 9 deletions tools/dataset_converters/update_infos_to_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,18 +961,22 @@ def update_waymo_infos(pkl_path, out_dir):
lidar_sweep['timestamp'] = ori_sweep['timestamp']
lidar_sweep['lidar_points']['lidar_path'] = Path(
ori_sweep['velodyne_path']).name
# delete the num_pts_feats and lidar2ego
del lidar_sweep['lidar_points']['num_pts_feats']
del lidar_sweep['lidar_points']['lidar2ego']
# TODO: refactor image_sweeps info when we really need it.
# image sweeps
# image_sweep = dict()
# image_sweep['sample_idx']= ori_sweep['image']['image_idx']
image_sweep = get_single_image_sweep(camera_types)
image_sweep['ego2global'] = ori_sweep['pose']
image_sweep['timestamp'] = ori_sweep['timestamp']
img_path = Path(ori_sweep['image_path']).name
for cam_idx, cam_key in enumerate(camera_types):
image_sweep['images'][cam_key]['img_path'] = img_path
# image_sweep = get_single_image_sweep(camera_types)
# image_sweep['ego2global'] = ori_sweep['pose']
# image_sweep['timestamp'] = ori_sweep['timestamp']
# img_path = Path(ori_sweep['image_path']).name
# for cam_idx, cam_key in enumerate(camera_types):
# image_sweep['images'][cam_key]['img_path'] = img_path

temp_data_info['lidar_sweeps'].append(lidar_sweep)
temp_data_info['image_sweeps'].append(image_sweep)
# temp_data_info['image_sweeps'].append(image_sweep)

anns = ori_info_dict.get('annos', None)
ignore_class_name = set()
Expand Down Expand Up @@ -1107,8 +1111,8 @@ def generate_waymo_camera_instances(ori_info_dict, cam_keys):

for cam_idx, cam_key in enumerate(cam_keys):
annos = copy.deepcopy(ori_info_dict['cam_sync_annos'])
if cam_idx != 0:
annos = convert_annos(ori_info_dict, cam_idx)

annos = convert_annos(ori_info_dict, cam_idx)

ann_infos = get_kitti_style_2d_boxes(
ori_info_dict, cam_idx, occluded=[0], annos=annos, dataset='waymo')
Expand Down
8 changes: 4 additions & 4 deletions tools/dataset_converters/waymo_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ def __init__(self,
self.tfrecord_pathnames = sorted(
glob(join(self.load_dir, '*.tfrecord')))

self.label_save_dir = f'{self.save_dir}/label_'
# self.label_save_dir = f'{self.save_dir}/label_'
self.label_all_save_dir = f'{self.save_dir}/label_all'
self.image_save_dir = f'{self.save_dir}/image_'
self.calib_save_dir = f'{self.save_dir}/calib'
self.point_cloud_save_dir = f'{self.save_dir}/velodyne'
self.pose_save_dir = f'{self.save_dir}/pose'
self.timestamp_save_dir = f'{self.save_dir}/timestamp'
if self.save_cam_sync_labels:
self.cam_sync_label_save_dir = f'{self.save_dir}/cam_sync_label_'
# self.cam_sync_label_save_dir = f'{self.save_dir}/cam_sync_label_'
self.cam_sync_label_all_save_dir = \
f'{self.save_dir}/cam_sync_label_all'

Expand Down Expand Up @@ -450,10 +450,10 @@ def create_folder(self):
self.pose_save_dir,
self.timestamp_save_dir,
]
dir_list2 = [self.label_save_dir, self.image_save_dir]
dir_list2 = [self.image_save_dir]
if self.save_cam_sync_labels:
dir_list1.append(self.cam_sync_label_all_save_dir)
dir_list2.append(self.cam_sync_label_save_dir)
# dir_list2.append(self.cam_sync_label_save_dir)
else:
dir_list1 = [
self.calib_save_dir, self.pose_save_dir,
Expand Down