Unverified Commit a481f5a8 authored by xiliu8006's avatar xiliu8006 Committed by GitHub
Browse files

[Enhance] Move train_cfg test_cfg to model (#307)

* Move train_cfg/test_cfg to model

* Move train_cfg/test_cfg to model

* Move train_cfg/test_cfg to model

* Move train_cfg/test_cfg to model

* Move train_cfg/test_cfg to model

* Move train_cfg/test_cfg to model

* Move train_cfg/test_cfg to model

* Move train_cfg and test_cfg into model

* modify centerpoint configs

* Modify docs

* modify build_detector

* modify test_config_build_detector

* modify build_detector parameters

* Adopt the same strategy in build_detector
parent a347ac75
_base_ = ['./centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py'] _base_ = ['./centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py']
test_cfg = dict(pts=dict(nms_type='circle')) model = dict(test_cfg=dict(pts=dict(nms_type='circle')))
...@@ -12,6 +12,5 @@ model = dict( ...@@ -12,6 +12,5 @@ model = dict(
padding=1, padding=1,
groups=4), groups=4),
init_bias=-2.19, init_bias=-2.19,
final_kernel=3))) final_kernel=3)),
test_cfg=dict(pts=dict(nms_type='circle')))
test_cfg = dict(pts=dict(nms_type='circle'))
...@@ -15,10 +15,10 @@ class_names = [ ...@@ -15,10 +15,10 @@ class_names = [
model = dict( model = dict(
pts_voxel_layer=dict(point_cloud_range=point_cloud_range), pts_voxel_layer=dict(point_cloud_range=point_cloud_range),
pts_bbox_head=dict(bbox_coder=dict(pc_range=point_cloud_range[:2]))) pts_bbox_head=dict(bbox_coder=dict(pc_range=point_cloud_range[:2])),
# model training and testing settings # model training and testing settings
train_cfg = dict(pts=dict(point_cloud_range=point_cloud_range)) train_cfg=dict(pts=dict(point_cloud_range=point_cloud_range)),
test_cfg = dict(pts=dict(pc_range=point_cloud_range[:2])) test_cfg=dict(pts=dict(pc_range=point_cloud_range[:2])))
dataset_type = 'NuScenesDataset' dataset_type = 'NuScenesDataset'
data_root = 'data/nuscenes/' data_root = 'data/nuscenes/'
......
_base_ = ['./centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py'] _base_ = ['./centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py']
test_cfg = dict(pts=dict(nms_type='circle')) model = dict(test_cfg=dict(pts=dict(nms_type='circle')))
...@@ -12,6 +12,5 @@ model = dict( ...@@ -12,6 +12,5 @@ model = dict(
padding=1, padding=1,
groups=4), groups=4),
init_bias=-2.19, init_bias=-2.19,
final_kernel=3))) final_kernel=3)),
test_cfg=dict(pts=dict(nms_type='circle')))
test_cfg = dict(pts=dict(nms_type='circle'))
...@@ -16,10 +16,10 @@ class_names = [ ...@@ -16,10 +16,10 @@ class_names = [
model = dict( model = dict(
pts_voxel_layer=dict(point_cloud_range=point_cloud_range), pts_voxel_layer=dict(point_cloud_range=point_cloud_range),
pts_voxel_encoder=dict(point_cloud_range=point_cloud_range), pts_voxel_encoder=dict(point_cloud_range=point_cloud_range),
pts_bbox_head=dict(bbox_coder=dict(pc_range=point_cloud_range[:2]))) pts_bbox_head=dict(bbox_coder=dict(pc_range=point_cloud_range[:2])),
# model training and testing settings # model training and testing settings
train_cfg = dict(pts=dict(point_cloud_range=point_cloud_range)) train_cfg=dict(pts=dict(point_cloud_range=point_cloud_range)),
test_cfg = dict(pts=dict(pc_range=point_cloud_range[:2])) test_cfg=dict(pts=dict(pc_range=point_cloud_range[:2])))
dataset_type = 'NuScenesDataset' dataset_type = 'NuScenesDataset'
data_root = 'data/nuscenes/' data_root = 'data/nuscenes/'
......
_base_ = ['./centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py'] _base_ = ['./centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py']
test_cfg = dict(pts=dict(nms_type='circle')) model = dict(test_cfg=dict(pts=dict(nms_type='circle')))
...@@ -12,6 +12,5 @@ model = dict( ...@@ -12,6 +12,5 @@ model = dict(
padding=1, padding=1,
groups=4), groups=4),
init_bias=-2.19, init_bias=-2.19,
final_kernel=3))) final_kernel=3)),
test_cfg=dict(pts=dict(nms_type='circle')))
test_cfg = dict(pts=dict(nms_type='circle'))
...@@ -70,10 +70,10 @@ model = dict( ...@@ -70,10 +70,10 @@ model = dict(
loss_weight=1.0), loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=0.8), loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=0.8),
loss_dir=dict( loss_dir=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2)),
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg = dict(
pts=dict(code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.25, 0.25])) pts=dict(code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.25, 0.25])))
``` ```
## Results ## Results
......
...@@ -42,7 +42,7 @@ model = dict( ...@@ -42,7 +42,7 @@ model = dict(
loss_weight=1.0), loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=0.8), loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=0.8),
loss_dir=dict( loss_dir=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2)),
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg=dict(
pts=dict(code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.25, 0.25])) pts=dict(code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.25, 0.25])))
...@@ -87,9 +87,9 @@ model = dict( ...@@ -87,9 +87,9 @@ model = dict(
loss_weight=1.0), loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=2.0), loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=2.0),
loss_dir=dict( loss_dir=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2)),
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg=dict(
pts=dict( pts=dict(
assigner=[ assigner=[
dict( # for Pedestrian dict( # for Pedestrian
...@@ -116,8 +116,8 @@ train_cfg = dict( ...@@ -116,8 +116,8 @@ train_cfg = dict(
], ],
allowed_border=0, allowed_border=0,
pos_weight=-1, pos_weight=-1,
debug=False)) debug=False)),
test_cfg = dict( test_cfg=dict(
pts=dict( pts=dict(
use_rotate_nms=True, use_rotate_nms=True,
nms_across_levels=False, nms_across_levels=False,
...@@ -125,7 +125,7 @@ test_cfg = dict( ...@@ -125,7 +125,7 @@ test_cfg = dict(
score_thr=0.1, score_thr=0.1,
min_bbox_size=0, min_bbox_size=0,
nms_pre=100, nms_pre=100,
max_num=50)) max_num=50)))
# dataset settings # dataset settings
dataset_type = 'KittiDataset' dataset_type = 'KittiDataset'
......
...@@ -130,9 +130,9 @@ model = dict( ...@@ -130,9 +130,9 @@ model = dict(
num_classes=10, num_classes=10,
loss_mask=dict( loss_mask=dict(
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0)) type='CrossEntropyLoss', use_mask=True, loss_weight=1.0))
])) ]),
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg=dict(
rpn=dict( rpn=dict(
assigner=dict( assigner=dict(
type='MaxIoUAssigner', type='MaxIoUAssigner',
...@@ -205,8 +205,8 @@ train_cfg = dict( ...@@ -205,8 +205,8 @@ train_cfg = dict(
mask_size=28, mask_size=28,
pos_weight=-1, pos_weight=-1,
debug=False) debug=False)
]) ]),
test_cfg = dict( test_cfg=dict(
rpn=dict( rpn=dict(
nms_across_levels=False, nms_across_levels=False,
nms_pre=1000, nms_pre=1000,
...@@ -218,4 +218,4 @@ test_cfg = dict( ...@@ -218,4 +218,4 @@ test_cfg = dict(
score_thr=0.001, score_thr=0.001,
nms=dict(type='nms', iou_threshold=0.5), nms=dict(type='nms', iou_threshold=0.5),
max_per_img=100, max_per_img=100,
mask_thr_binary=0.5)) mask_thr_binary=0.5)))
...@@ -112,9 +112,9 @@ model = dict( ...@@ -112,9 +112,9 @@ model = dict(
type='CrossEntropyLoss', type='CrossEntropyLoss',
use_sigmoid=True, use_sigmoid=True,
reduction='sum', reduction='sum',
loss_weight=1.0)))) loss_weight=1.0))),
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg=dict(
rpn=dict( rpn=dict(
assigner=[ assigner=[
dict( # for Pedestrian dict( # for Pedestrian
...@@ -153,21 +153,24 @@ train_cfg = dict( ...@@ -153,21 +153,24 @@ train_cfg = dict(
assigner=[ assigner=[
dict( # for Pedestrian dict( # for Pedestrian
type='MaxIoUAssigner', type='MaxIoUAssigner',
iou_calculator=dict(type='BboxOverlaps3D', coordinate='lidar'), iou_calculator=dict(
type='BboxOverlaps3D', coordinate='lidar'),
pos_iou_thr=0.55, pos_iou_thr=0.55,
neg_iou_thr=0.55, neg_iou_thr=0.55,
min_pos_iou=0.55, min_pos_iou=0.55,
ignore_iof_thr=-1), ignore_iof_thr=-1),
dict( # for Cyclist dict( # for Cyclist
type='MaxIoUAssigner', type='MaxIoUAssigner',
iou_calculator=dict(type='BboxOverlaps3D', coordinate='lidar'), iou_calculator=dict(
type='BboxOverlaps3D', coordinate='lidar'),
pos_iou_thr=0.55, pos_iou_thr=0.55,
neg_iou_thr=0.55, neg_iou_thr=0.55,
min_pos_iou=0.55, min_pos_iou=0.55,
ignore_iof_thr=-1), ignore_iof_thr=-1),
dict( # for Car dict( # for Car
type='MaxIoUAssigner', type='MaxIoUAssigner',
iou_calculator=dict(type='BboxOverlaps3D', coordinate='lidar'), iou_calculator=dict(
type='BboxOverlaps3D', coordinate='lidar'),
pos_iou_thr=0.55, pos_iou_thr=0.55,
neg_iou_thr=0.55, neg_iou_thr=0.55,
min_pos_iou=0.55, min_pos_iou=0.55,
...@@ -183,8 +186,8 @@ train_cfg = dict( ...@@ -183,8 +186,8 @@ train_cfg = dict(
add_gt_as_proposals=False, add_gt_as_proposals=False,
return_iou=True), return_iou=True),
cls_pos_thr=0.75, cls_pos_thr=0.75,
cls_neg_thr=0.25)) cls_neg_thr=0.25)),
test_cfg = dict( test_cfg=dict(
rpn=dict( rpn=dict(
nms_pre=1024, nms_pre=1024,
nms_post=100, nms_post=100,
...@@ -193,7 +196,10 @@ test_cfg = dict( ...@@ -193,7 +196,10 @@ test_cfg = dict(
score_thr=0, score_thr=0,
use_rotate_nms=True), use_rotate_nms=True),
rcnn=dict( rcnn=dict(
use_rotate_nms=True, use_raw_score=True, nms_thr=0.01, score_thr=0.1)) use_rotate_nms=True,
use_raw_score=True,
nms_thr=0.01,
score_thr=0.1)))
# dataset settings # dataset settings
dataset_type = 'KittiDataset' dataset_type = 'KittiDataset'
......
...@@ -17,9 +17,9 @@ model = dict( ...@@ -17,9 +17,9 @@ model = dict(
roi_head=dict( roi_head=dict(
num_classes=1, num_classes=1,
semantic_head=dict(num_classes=1), semantic_head=dict(num_classes=1),
bbox_head=dict(num_classes=1))) bbox_head=dict(num_classes=1)),
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg=dict(
_delete_=True, _delete_=True,
rpn=dict( rpn=dict(
assigner=dict( assigner=dict(
...@@ -57,8 +57,8 @@ train_cfg = dict( ...@@ -57,8 +57,8 @@ train_cfg = dict(
add_gt_as_proposals=False, add_gt_as_proposals=False,
return_iou=True), return_iou=True),
cls_pos_thr=0.75, cls_pos_thr=0.75,
cls_neg_thr=0.25)) cls_neg_thr=0.25)),
test_cfg = dict( test_cfg=dict(
rpn=dict( rpn=dict(
nms_pre=1024, nms_pre=1024,
nms_post=100, nms_post=100,
...@@ -67,7 +67,10 @@ test_cfg = dict( ...@@ -67,7 +67,10 @@ test_cfg = dict(
score_thr=0, score_thr=0,
use_rotate_nms=True), use_rotate_nms=True),
rcnn=dict( rcnn=dict(
use_rotate_nms=True, use_raw_score=True, nms_thr=0.01, score_thr=0.1)) use_rotate_nms=True,
use_raw_score=True,
nms_thr=0.01,
score_thr=0.1)))
# dataset settings # dataset settings
dataset_type = 'KittiDataset' dataset_type = 'KittiDataset'
......
...@@ -12,9 +12,9 @@ model = dict( ...@@ -12,9 +12,9 @@ model = dict(
ranges=[[0, -39.68, -1.78, 69.12, 39.68, -1.78]], ranges=[[0, -39.68, -1.78, 69.12, 39.68, -1.78]],
sizes=[[1.6, 3.9, 1.56]], sizes=[[1.6, 3.9, 1.56]],
rotations=[0, 1.57], rotations=[0, 1.57],
reshape_out=True))) reshape_out=True)),
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg=dict(
_delete_=True, _delete_=True,
assigner=dict( assigner=dict(
type='MaxIoUAssigner', type='MaxIoUAssigner',
...@@ -25,7 +25,7 @@ train_cfg = dict( ...@@ -25,7 +25,7 @@ train_cfg = dict(
ignore_iof_thr=-1), ignore_iof_thr=-1),
allowed_border=0, allowed_border=0,
pos_weight=-1, pos_weight=-1,
debug=False) debug=False))
# dataset settings # dataset settings
dataset_type = 'KittiDataset' dataset_type = 'KittiDataset'
......
...@@ -19,10 +19,9 @@ model = dict( ...@@ -19,10 +19,9 @@ model = dict(
ranges=[[-74.88, -74.88, -0.0345, 74.88, 74.88, -0.0345]], ranges=[[-74.88, -74.88, -0.0345, 74.88, 74.88, -0.0345]],
sizes=[[2.08, 4.73, 1.77]], sizes=[[2.08, 4.73, 1.77]],
rotations=[0, 1.57], rotations=[0, 1.57],
reshape_out=True))) reshape_out=True)),
# model training and testing settings
# model training and testing settings train_cfg=dict(
train_cfg = dict(
_delete_=True, _delete_=True,
pts=dict( pts=dict(
assigner=dict( assigner=dict(
...@@ -35,4 +34,4 @@ train_cfg = dict( ...@@ -35,4 +34,4 @@ train_cfg = dict(
allowed_border=0, allowed_border=0,
code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
pos_weight=-1, pos_weight=-1,
debug=False)) debug=False)))
...@@ -16,10 +16,9 @@ model = dict( ...@@ -16,10 +16,9 @@ model = dict(
ranges=[[-74.88, -74.88, -0.0345, 74.88, 74.88, -0.0345]], ranges=[[-74.88, -74.88, -0.0345, 74.88, 74.88, -0.0345]],
sizes=[[2.08, 4.73, 1.77]], sizes=[[2.08, 4.73, 1.77]],
rotations=[0, 1.57], rotations=[0, 1.57],
reshape_out=True))) reshape_out=True)),
# model training and testing settings
# model training and testing settings train_cfg=dict(
train_cfg = dict(
_delete_=True, _delete_=True,
pts=dict( pts=dict(
assigner=dict( assigner=dict(
...@@ -32,4 +31,4 @@ train_cfg = dict( ...@@ -32,4 +31,4 @@ train_cfg = dict(
allowed_border=0, allowed_border=0,
code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
pos_weight=-1, pos_weight=-1,
debug=False)) debug=False)))
...@@ -14,9 +14,9 @@ model = dict( ...@@ -14,9 +14,9 @@ model = dict(
ranges=[[0, -40.0, -1.78, 70.4, 40.0, -1.78]], ranges=[[0, -40.0, -1.78, 70.4, 40.0, -1.78]],
sizes=[[1.6, 3.9, 1.56]], sizes=[[1.6, 3.9, 1.56]],
rotations=[0, 1.57], rotations=[0, 1.57],
reshape_out=True))) reshape_out=True)),
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg=dict(
_delete_=True, _delete_=True,
assigner=dict( assigner=dict(
type='MaxIoUAssigner', type='MaxIoUAssigner',
...@@ -27,4 +27,4 @@ train_cfg = dict( ...@@ -27,4 +27,4 @@ train_cfg = dict(
ignore_iof_thr=-1), ignore_iof_thr=-1),
allowed_border=0, allowed_border=0,
pos_weight=-1, pos_weight=-1,
debug=False) debug=False))
...@@ -155,10 +155,9 @@ model = dict( ...@@ -155,10 +155,9 @@ model = dict(
loss_weight=1.0), loss_weight=1.0),
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0), loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0),
loss_dir=dict( loss_dir=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2)),
# model training and testing settings
# model training and testing settings train_cfg=dict(
train_cfg = dict(
_delete_=True, _delete_=True,
pts=dict( pts=dict(
assigner=[ assigner=[
...@@ -236,4 +235,4 @@ train_cfg = dict( ...@@ -236,4 +235,4 @@ train_cfg = dict(
allowed_border=0, allowed_border=0,
code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2], code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.2, 0.2],
pos_weight=-1, pos_weight=-1,
debug=False)) debug=False)))
...@@ -44,6 +44,32 @@ For `1x`/`2x`, initial learning rate decays by a factor of 10 at the 8/16th and ...@@ -44,6 +44,32 @@ For `1x`/`2x`, initial learning rate decays by a factor of 10 at the 8/16th and
For `20e`, initial learning rate decays by a factor of 10 at the 16th and 19th epochs. For `20e`, initial learning rate decays by a factor of 10 at the 16th and 19th epochs.
- `{dataset}`: dataset like `nus-3d`, `kitti-3d`, `lyft-3d`, `scannet-3d`, `sunrgbd-3d`. We also indicate the number of classes we are using if there exist multiple settings, e.g., `kitti-3d-3class` and `kitti-3d-car` means training on KITTI dataset with 3 classes and single class, respectively. - `{dataset}`: dataset like `nus-3d`, `kitti-3d`, `lyft-3d`, `scannet-3d`, `sunrgbd-3d`. We also indicate the number of classes we are using if there exist multiple settings, e.g., `kitti-3d-3class` and `kitti-3d-car` means training on KITTI dataset with 3 classes and single class, respectively.
## Deprecated train_cfg/test_cfg
Following MMDetection, the `train_cfg` and `test_cfg` are deprecated in config file, please specify them in the model config. The original config structure is as below.
```python
# deprecated
model = dict(
type=...,
...
)
train_cfg=dict(...)
test_cfg=dict(...)
```
The migration example is as below.
```python
# recommended
model = dict(
type=...,
...
train_cfg=dict(...),
test_cfg=dict(...)
)
```
## An example of VoteNet ## An example of VoteNet
```python ```python
...@@ -144,16 +170,16 @@ model = dict( ...@@ -144,16 +170,16 @@ model = dict(
semantic_loss=dict( # Config to semantic loss semantic_loss=dict( # Config to semantic loss
type='CrossEntropyLoss', # Type of loss type='CrossEntropyLoss', # Type of loss
reduction='sum', # Specifies the reduction to apply to the output reduction='sum', # Specifies the reduction to apply to the output
loss_weight=1.0))) # Loss weight of the semantic loss loss_weight=1.0)), # Loss weight of the semantic loss
train_cfg = dict( # Config of training hyperparameters for votenet train_cfg = dict( # Config of training hyperparameters for votenet
pos_distance_thr=0.3, # distance >= threshold 0.3 will be taken as positive samples pos_distance_thr=0.3, # distance >= threshold 0.3 will be taken as positive samples
neg_distance_thr=0.6, # distance < threshold 0.6 will be taken as positive samples neg_distance_thr=0.6, # distance < threshold 0.6 will be taken as positive samples
sample_mod='vote') # Mode of the sampling method sample_mod='vote'), # Mode of the sampling method
test_cfg = dict( # Config of testing hyperparameters for votenet test_cfg = dict( # Config of testing hyperparameters for votenet
sample_mod='seed', # Mode of the sampling method sample_mod='seed', # Mode of the sampling method
nms_thr=0.25, # The threshold to be used during NMS nms_thr=0.25, # The threshold to be used during NMS
score_thr=0.8, # Threshold to filter out boxes score_thr=0.8, # Threshold to filter out boxes
per_class_proposal=False) # Whether to use per_class_proposal per_class_proposal=False)) # Whether to use per_class_proposal
dataset_type = 'ScanNetDataset' # Type of the dataset dataset_type = 'ScanNetDataset' # Type of the dataset
data_root = './data/scannet/' # Root path of the data data_root = './data/scannet/' # Root path of the data
class_names = ('cabinet', 'bed', 'chair', 'sofa', 'table', 'door', 'window', class_names = ('cabinet', 'bed', 'chair', 'sofa', 'table', 'door', 'window',
......
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