Alfred Liu commited on
Commit
1a2cae5
·
1 Parent(s): 6ce1271

Release model: r101_nuimg_1408x512

Browse files
Files changed (4) hide show
  1. README.md +9 -8
  2. models/sparsebev_head.py +8 -0
  3. models/utils.py +20 -5
  4. val.py +16 -12
README.md CHANGED
@@ -4,14 +4,15 @@ This is the official PyTorch implementation for paper [SparseBEV: High-Performan
4
 
5
  ## Model Zoo
6
 
7
- | Setting | Pretrain | Training Cost | NDS | FPS | Config | Weights |
8
- |----------|----------|---------------|-----|-----|--------|---------|
9
- | r50_nuimg_704x256 | [nuImages](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/nuimages_semseg/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim_20201009_124951-40963960.pth) | 21h (8x2080Ti) | 55.6 | 15.8 | [config](configs/r50_nuimg_704x256.py) | [weights](https://drive.google.com/file/d/1ft34-pxLpHGo2Aw-jowEtCxyXcqszHNn/view) |
10
- | r50_nuimg_704x256_400q_36ep | [nuImages](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/nuimages_semseg/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim_20201009_124951-40963960.pth) | 28h (8x2080Ti) | 55.8 | 23.5 | [config](configs/r50_nuimg_704x256_400q_36ep.py) | [weights](https://drive.google.com/file/d/1C_Vn3iiSnSW1Dw1r0DkjJMwvHC5Y3zTN/view) |
 
11
 
12
  * We use `r50_nuimg_704x256` for ablation studies and `r50_nuimg_704x256_400q_36ep` for comparison with others.
13
  * We recommend using `r50_nuimg_704x256` to validate new ideas since it trains faster and the result is more stable.
14
- * FPS is measured with AMD 5800X CPU and RTX 3090 GPU.
15
  * The noise is around 0.3 NDS.
16
 
17
  ## Environment
@@ -107,14 +108,14 @@ Single-GPU evaluation:
107
 
108
  ```
109
  export CUDA_VISIBLE_DEVICES=0
110
- python val.py --config configs/r50_nuimg_704x256_400q_36ep.py --weights checkpoints/r50_nuimg_704x256_400q_36ep.pth
111
  ```
112
 
113
  Multi-GPU evaluation:
114
 
115
  ```
116
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
117
- torchrun --nproc_per_node 8 val.py --config configs/r50_nuimg_704x256_400q_36ep.py --weights checkpoints/r50_nuimg_704x256_400q_36ep.pth
118
  ```
119
 
120
  ## Timing
@@ -123,7 +124,7 @@ FPS is measured with a single GPU:
123
 
124
  ```
125
  export CUDA_VISIBLE_DEVICES=0
126
- python timing.py --config configs/r50_nuimg_704x256_400q_36ep.py --weights checkpoints/r50_nuimg_704x256_400q_36ep.pth
127
  ```
128
 
129
  ## Acknowledgements
 
4
 
5
  ## Model Zoo
6
 
7
+ | Setting | Pretrain | Training Cost | NDS | FPS | Weights |
8
+ |----------|----------|---------------|-----|-----|---------|
9
+ | [r50_nuimg_704x256](configs/r50_nuimg_704x256.py) | [nuImages](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/nuimages_semseg/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim_20201009_124951-40963960.pth) | 21h (8x2080Ti) | 55.6 | 15.8 | [weights](https://drive.google.com/file/d/1ft34-pxLpHGo2Aw-jowEtCxyXcqszHNn/view) |
10
+ | [r50_nuimg_704x256_400q_36ep](configs/r50_nuimg_704x256_400q_36ep.py) | [nuImages](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/nuimages_semseg/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim_20201009_124951-40963960.pth) | 28h (8x2080Ti) | 55.8 | 23.5 | [weights](https://drive.google.com/file/d/1C_Vn3iiSnSW1Dw1r0DkjJMwvHC5Y3zTN/view) |
11
+ | [r101_nuimg_1408x512](configs/r101_nuimg_1408x512.py) | [nuImages](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/nuimages_semseg/cascade_mask_rcnn_r101_fpn_1x_nuim/cascade_mask_rcnn_r101_fpn_1x_nuim_20201024_134804-45215b1e.pth) | 2d8h (8xV100) | 59.2 | 6.5 | [weights](https://drive.google.com/file/d/1dKu5cR1fuo-O0ynyBh-RCPtHrgut29mN/view) |
12
 
13
  * We use `r50_nuimg_704x256` for ablation studies and `r50_nuimg_704x256_400q_36ep` for comparison with others.
14
  * We recommend using `r50_nuimg_704x256` to validate new ideas since it trains faster and the result is more stable.
15
+ * FPS is measured with AMD 5800X CPU and RTX 3090 GPU (without `fp16`).
16
  * The noise is around 0.3 NDS.
17
 
18
  ## Environment
 
108
 
109
  ```
110
  export CUDA_VISIBLE_DEVICES=0
111
+ python val.py --config configs/r50_nuimg_704x256.py --weights checkpoints/r50_nuimg_704x256.pth
112
  ```
113
 
114
  Multi-GPU evaluation:
115
 
116
  ```
117
  export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
118
+ torchrun --nproc_per_node 8 val.py --config configs/r50_nuimg_704x256.py --weights checkpoints/r50_nuimg_704x256.pth
119
  ```
120
 
121
  ## Timing
 
124
 
125
  ```
126
  export CUDA_VISIBLE_DEVICES=0
127
+ python timing.py --config configs/r50_nuimg_704x256.py --weights checkpoints/r50_nuimg_704x256.pth
128
  ```
129
 
130
  ## Acknowledgements
models/sparsebev_head.py CHANGED
@@ -8,6 +8,7 @@ from mmdet.models.dense_heads import DETRHead
8
  from mmdet3d.core.bbox.coders import build_bbox_coder
9
  from mmdet3d.core.bbox.structures.lidar_box3d import LiDARInstance3DBoxes
10
  from .bbox.utils import normalize_bbox, encode_bbox
 
11
 
12
 
13
  @HEADS.register_module()
@@ -462,6 +463,13 @@ class SparseBEVHead(DETRHead):
462
  preds = preds_dicts[i]
463
  bboxes = preds['bboxes']
464
  bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5
 
 
 
 
 
 
 
465
  bboxes = LiDARInstance3DBoxes(bboxes, 9)
466
  scores = preds['scores']
467
  labels = preds['labels']
 
8
  from mmdet3d.core.bbox.coders import build_bbox_coder
9
  from mmdet3d.core.bbox.structures.lidar_box3d import LiDARInstance3DBoxes
10
  from .bbox.utils import normalize_bbox, encode_bbox
11
+ from .utils import VERSION
12
 
13
 
14
  @HEADS.register_module()
 
463
  preds = preds_dicts[i]
464
  bboxes = preds['bboxes']
465
  bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 5] * 0.5
466
+
467
+ if VERSION.name == 'v0.17.1':
468
+ import copy
469
+ w, l = copy.deepcopy(bboxes[:, 3]), copy.deepcopy(bboxes[:, 4])
470
+ bboxes[:, 3], bboxes[:, 4] = l, w
471
+ bboxes[:, 6] = -bboxes[:, 6] - math.pi / 2
472
+
473
  bboxes = LiDARInstance3DBoxes(bboxes, 9)
474
  scores = preds['scores']
475
  labels = preds['labels']
models/utils.py CHANGED
@@ -62,11 +62,18 @@ def rotation_3d_in_axis(points, angles):
62
  ones = torch.ones_like(rot_cos)
63
  zeros = torch.zeros_like(rot_cos)
64
 
65
- rot_mat_T = torch.stack([
66
- rot_cos, rot_sin, zeros,
67
- -rot_sin, rot_cos, zeros,
68
- zeros, zeros, ones,
69
- ]).transpose(0, 1).reshape(-1, 3, 3)
 
 
 
 
 
 
 
70
 
71
  points = torch.bmm(points, rot_mat_T)
72
 
@@ -307,3 +314,11 @@ class DumpConfig:
307
 
308
 
309
  DUMP = DumpConfig()
 
 
 
 
 
 
 
 
 
62
  ones = torch.ones_like(rot_cos)
63
  zeros = torch.zeros_like(rot_cos)
64
 
65
+ if VERSION.name == 'v0.17.1':
66
+ rot_mat_T = torch.stack([
67
+ rot_cos, -rot_sin, zeros,
68
+ rot_sin, rot_cos, zeros,
69
+ zeros, zeros, ones,
70
+ ]).transpose(0, 1).reshape(-1, 3, 3)
71
+ else:
72
+ rot_mat_T = torch.stack([
73
+ rot_cos, rot_sin, zeros,
74
+ -rot_sin, rot_cos, zeros,
75
+ zeros, zeros, ones,
76
+ ]).transpose(0, 1).reshape(-1, 3, 3)
77
 
78
  points = torch.bmm(points, rot_mat_T)
79
 
 
314
 
315
 
316
  DUMP = DumpConfig()
317
+
318
+
319
+ # for backward compatibility
320
+ class Version:
321
+ def __init__(self):
322
+ self.name = 'v1.0.0'
323
+
324
+ VERSION = Version()
val.py CHANGED
@@ -13,6 +13,7 @@ from mmcv.runner import load_checkpoint
13
  from mmdet.apis import set_random_seed, multi_gpu_test, single_gpu_test
14
  from mmdet3d.datasets import build_dataset, build_dataloader
15
  from mmdet3d.models import build_model
 
16
 
17
 
18
  def evaluate(dataset, results, epoch):
@@ -117,20 +118,23 @@ def main():
117
  else:
118
  model = MMDataParallel(model, [0])
119
 
120
- if os.path.isfile(args.weights):
121
- logging.info('Loading checkpoint from %s' % args.weights)
122
- load_checkpoint(
123
- model, args.weights, map_location='cuda', strict=True,
124
- logger=logging.Logger(__name__, logging.ERROR)
125
- )
126
 
127
- if world_size > 1:
128
- results = multi_gpu_test(model, val_loader, gpu_collect=True)
129
- else:
130
- results = single_gpu_test(model, val_loader)
131
 
132
- if local_rank == 0:
133
- evaluate(val_dataset, results, -1)
 
 
 
 
 
134
 
135
 
136
  if __name__ == '__main__':
 
13
  from mmdet.apis import set_random_seed, multi_gpu_test, single_gpu_test
14
  from mmdet3d.datasets import build_dataset, build_dataloader
15
  from mmdet3d.models import build_model
16
+ from models.utils import VERSION
17
 
18
 
19
  def evaluate(dataset, results, epoch):
 
118
  else:
119
  model = MMDataParallel(model, [0])
120
 
121
+ logging.info('Loading checkpoint from %s' % args.weights)
122
+ checkpoint = load_checkpoint(
123
+ model, args.weights, map_location='cuda', strict=True,
124
+ logger=logging.Logger(__name__, logging.ERROR)
125
+ )
 
126
 
127
+ if 'version' in checkpoint:
128
+ VERSION.name = checkpoint['version']
129
+ logging.info(VERSION.name)
 
130
 
131
+ if world_size > 1:
132
+ results = multi_gpu_test(model, val_loader, gpu_collect=True)
133
+ else:
134
+ results = single_gpu_test(model, val_loader)
135
+
136
+ if local_rank == 0:
137
+ evaluate(val_dataset, results, -1)
138
 
139
 
140
  if __name__ == '__main__':