Commit ff8623e1 authored by zhangwenwei's avatar zhangwenwei
Browse files

Fix bugs during training runtime

parent 9d32fbc4
......@@ -130,7 +130,7 @@ input_modality = dict(
use_lidar=True,
use_depth=False,
use_lidar_intensity=True,
use_camera=True,
use_camera=False,
)
db_sampler = dict(
root_path=data_root,
......@@ -156,23 +156,12 @@ train_pipeline = [
dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range),
dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range),
dict(type='PointShuffle'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle3D', class_names=class_names),
dict(type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']),
]
test_pipeline = [
dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range),
dict(
type='Resize',
img_scale=[
(1280, 720),
],
multiscale_mode='value',
keep_ratio=True),
dict(type='RandomFlip3D', flip_ratio=0),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(
type='DefaultFormatBundle3D',
class_names=class_names,
......@@ -216,7 +205,7 @@ lr_config = dict(
warmup='linear',
warmup_iters=1000,
warmup_ratio=1.0 / 1000,
step=[16, 19])
step=[20, 23])
momentum_config = None
checkpoint_config = dict(interval=1)
# yapf:disable
......@@ -229,10 +218,10 @@ log_config = dict(
])
# yapf:enable
# runtime settings
total_epochs = 20
total_epochs = 24
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = './work_dirs/pp_secfpn_80e'
work_dir = './work_dirs/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d'
load_from = None
resume_from = None
workflow = [('train', 1)]
......@@ -38,15 +38,16 @@ def bbox_overlaps_nearest_3d(bboxes1, bboxes2, mode='iou', is_aligned=False):
"""Calculate nearest 3D IoU
Args:
bboxes1: Tensor, shape (N, 7) [x, y, z, h, w, l, ry]?
bboxes2: Tensor, shape (M, 7) [x, y, z, h, w, l, ry]?
bboxes1: Tensor, shape (N, 7+N) [x, y, z, h, w, l, ry, v]
bboxes2: Tensor, shape (M, 7+N) [x, y, z, h, w, l, ry, v]
mode: mode (str): "iou" (intersection over union) or iof
(intersection over foreground).
Return:
iou: (M, N) not support aligned mode currently
"""
assert bboxes1.size(-1) == bboxes2.size(-1) == 7
assert bboxes1.size(-1) >= 7
assert bboxes2.size(-1) >= 7
column_index1 = bboxes1.new_tensor([0, 1, 3, 4, 6], dtype=torch.long)
rbboxes1_bev = bboxes1.index_select(dim=-1, index=column_index1)
rbboxes2_bev = bboxes2.index_select(dim=-1, index=column_index1)
......
import mmcv
import numpy as np
from mmcv.utils import build_from_cfg
......@@ -34,7 +35,42 @@ class RandomFlip3D(RandomFlip):
return gt_bboxes_3d, points
def __call__(self, input_dict):
super(RandomFlip3D, self).__call__(input_dict)
# filp 2D image and its annotations
if 'flip' not in input_dict:
flip = True if np.random.rand() < self.flip_ratio else False
input_dict['flip'] = flip
if 'flip_direction' not in input_dict:
input_dict['flip_direction'] = self.direction
if input_dict['flip']:
# flip image
if 'img' in input_dict:
if isinstance(input_dict['img'], list):
input_dict['img'] = [
mmcv.imflip(
img, direction=input_dict['flip_direction'])
for img in input_dict['img']
]
else:
input_dict['img'] = mmcv.imflip(
input_dict['img'],
direction=input_dict['flip_direction'])
# flip bboxes
for key in input_dict.get('bbox_fields', []):
input_dict[key] = self.bbox_flip(input_dict[key],
input_dict['img_shape'],
input_dict['flip_direction'])
# flip masks
for key in input_dict.get('mask_fields', []):
input_dict[key] = [
mmcv.imflip(mask, direction=input_dict['flip_direction'])
for mask in input_dict[key]
]
# flip segs
for key in input_dict.get('seg_fields', []):
input_dict[key] = mmcv.imflip(
input_dict[key], direction=input_dict['flip_direction'])
if self.sync_2d:
input_dict['pcd_flip'] = input_dict['flip']
else:
......@@ -50,6 +86,10 @@ class RandomFlip3D(RandomFlip):
input_dict['points'] = points
return input_dict
def __repr__(self):
return self.__class__.__name__ + '(flip_ratio={}, sync_2d={})'.format(
self.flip_ratio, self.sync_2d)
@PIPELINES.register_module
class ObjectSample(object):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment