diff --git a/configs/cascade_mask_rcnn_r101_fpn_1x.py b/configs/cascade_mask_rcnn_r101_fpn_1x.py index 0ad9c88207b061ed6be72a35fb4687081fc72934..5ac4075e32f11cbd9b0661e27973b289c05aa4e6 100644 --- a/configs/cascade_mask_rcnn_r101_fpn_1x.py +++ b/configs/cascade_mask_rcnn_r101_fpn_1x.py @@ -174,8 +174,7 @@ test_cfg = dict( score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_mask_rcnn_r50_caffe_c4_1x.py b/configs/cascade_mask_rcnn_r50_caffe_c4_1x.py index dd5f356b4df35256b4ae9e0a1911907667cb4633..7ef36d5514b700d24fafc2aa7b72a89bfbf54761 100644 --- a/configs/cascade_mask_rcnn_r50_caffe_c4_1x.py +++ b/configs/cascade_mask_rcnn_r50_caffe_c4_1x.py @@ -176,8 +176,7 @@ test_cfg = dict( score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_mask_rcnn_r50_fpn_1x.py b/configs/cascade_mask_rcnn_r50_fpn_1x.py index c9f007ed653b76b09d9e680143a5fa9bb5261af4..e23e159d9bd9c3b553f584dddf5f246ec0892b91 100644 --- a/configs/cascade_mask_rcnn_r50_fpn_1x.py +++ b/configs/cascade_mask_rcnn_r50_fpn_1x.py @@ -174,8 +174,7 @@ test_cfg = dict( score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_mask_rcnn_x101_32x4d_fpn_1x.py b/configs/cascade_mask_rcnn_x101_32x4d_fpn_1x.py index 3167be4c340c5feddf09fce9984a09542ae9370d..723462c22c8463644880982be06564be185838e9 100644 --- a/configs/cascade_mask_rcnn_x101_32x4d_fpn_1x.py +++ b/configs/cascade_mask_rcnn_x101_32x4d_fpn_1x.py @@ -176,8 +176,7 @@ test_cfg = dict( score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_mask_rcnn_x101_64x4d_fpn_1x.py b/configs/cascade_mask_rcnn_x101_64x4d_fpn_1x.py index 0c5434ead4d6df865180cf4edb0b45c73b54cb5f..b8ad46225dc57a1555dc1ff35c5d5a1778680a38 100644 --- a/configs/cascade_mask_rcnn_x101_64x4d_fpn_1x.py +++ b/configs/cascade_mask_rcnn_x101_64x4d_fpn_1x.py @@ -176,8 +176,7 @@ test_cfg = dict( score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_rcnn_r101_fpn_1x.py b/configs/cascade_rcnn_r101_fpn_1x.py index a790c2bd55bf9e0b7205876d6805b909de75f6a3..9f3d08801e479187ea305456887b4ac78850287b 100644 --- a/configs/cascade_rcnn_r101_fpn_1x.py +++ b/configs/cascade_rcnn_r101_fpn_1x.py @@ -155,8 +155,7 @@ test_cfg = dict( nms_thr=0.7, min_bbox_size=0), rcnn=dict( - score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100), - keep_all_stages=False) + score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_rcnn_r50_caffe_c4_1x.py b/configs/cascade_rcnn_r50_caffe_c4_1x.py index 0dd10abb00b993e8e51c51d92780ae914f05dd08..5722d416cb47c5f0e79c1dad0a91cc8573aeadd9 100644 --- a/configs/cascade_rcnn_r50_caffe_c4_1x.py +++ b/configs/cascade_rcnn_r50_caffe_c4_1x.py @@ -164,8 +164,7 @@ test_cfg = dict( nms_thr=0.7, min_bbox_size=0), rcnn=dict( - score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100), - keep_all_stages=False) + score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_rcnn_r50_fpn_1x.py b/configs/cascade_rcnn_r50_fpn_1x.py index 96269fab0051dcf6ca591b305f18d1bf7ed2e090..56e3ee9c7986533073db4d934c4324466feb084f 100644 --- a/configs/cascade_rcnn_r50_fpn_1x.py +++ b/configs/cascade_rcnn_r50_fpn_1x.py @@ -155,8 +155,7 @@ test_cfg = dict( nms_thr=0.7, min_bbox_size=0), rcnn=dict( - score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100), - keep_all_stages=False) + score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_rcnn_x101_32x4d_fpn_1x.py b/configs/cascade_rcnn_x101_32x4d_fpn_1x.py index 6de3d37d7177423e7347a7c62aa2c5d1b80e8b36..397d0b846bdf9bb60cefb07f17a52bfc2417ba23 100644 --- a/configs/cascade_rcnn_x101_32x4d_fpn_1x.py +++ b/configs/cascade_rcnn_x101_32x4d_fpn_1x.py @@ -157,8 +157,7 @@ test_cfg = dict( nms_thr=0.7, min_bbox_size=0), rcnn=dict( - score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100), - keep_all_stages=False) + score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/cascade_rcnn_x101_64x4d_fpn_1x.py b/configs/cascade_rcnn_x101_64x4d_fpn_1x.py index d6e9d1f6f12dc0c8583d1d997703c2a94b6ae369..0d31f88332146565ac283415deecdd8c53a6761f 100644 --- a/configs/cascade_rcnn_x101_64x4d_fpn_1x.py +++ b/configs/cascade_rcnn_x101_64x4d_fpn_1x.py @@ -157,8 +157,7 @@ test_cfg = dict( nms_thr=0.7, min_bbox_size=0), rcnn=dict( - score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100), - keep_all_stages=False) + score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/dcn/cascade_mask_rcnn_dconv_c3-c5_r50_fpn_1x.py b/configs/dcn/cascade_mask_rcnn_dconv_c3-c5_r50_fpn_1x.py index 27476d3a9a0434f5a458e8f15eb7cb833fa742cf..c27fff20cd53d578e716f26d477d62ed25362bcd 100644 --- a/configs/dcn/cascade_mask_rcnn_dconv_c3-c5_r50_fpn_1x.py +++ b/configs/dcn/cascade_mask_rcnn_dconv_c3-c5_r50_fpn_1x.py @@ -177,8 +177,7 @@ test_cfg = dict( score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/dcn/cascade_rcnn_dconv_c3-c5_r50_fpn_1x.py b/configs/dcn/cascade_rcnn_dconv_c3-c5_r50_fpn_1x.py index 9f9f10cf0ad7318ca7edebd9994a90ed43ff424f..2a4740b392bcd07cc8cd9c2204d0734811fc44ec 100644 --- a/configs/dcn/cascade_rcnn_dconv_c3-c5_r50_fpn_1x.py +++ b/configs/dcn/cascade_rcnn_dconv_c3-c5_r50_fpn_1x.py @@ -158,8 +158,7 @@ test_cfg = dict( nms_thr=0.7, min_bbox_size=0), rcnn=dict( - score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100), - keep_all_stages=False) + score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/hrnet/cascade_mask_rcnn_hrnetv2p_w32_20e.py b/configs/hrnet/cascade_mask_rcnn_hrnetv2p_w32_20e.py index 17fe9455bb2c8735db2d5aa24f9aae05e4cd1b4b..ae76e5a26985c90eeac810a72d0cdcbb2a415dd5 100644 --- a/configs/hrnet/cascade_mask_rcnn_hrnetv2p_w32_20e.py +++ b/configs/hrnet/cascade_mask_rcnn_hrnetv2p_w32_20e.py @@ -190,8 +190,7 @@ test_cfg = dict( score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/hrnet/cascade_rcnn_hrnetv2p_w32_20e.py b/configs/hrnet/cascade_rcnn_hrnetv2p_w32_20e.py index 65eedd15a575aa803d21cd083b3fdf42dee239f0..48c013764b746dab30a61a664a2f737f9aab54f0 100644 --- a/configs/hrnet/cascade_rcnn_hrnetv2p_w32_20e.py +++ b/configs/hrnet/cascade_rcnn_hrnetv2p_w32_20e.py @@ -171,8 +171,7 @@ test_cfg = dict( nms_thr=0.7, min_bbox_size=0), rcnn=dict( - score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100), - keep_all_stages=False) + score_thr=0.05, nms=dict(type='nms', iou_thr=0.5), max_per_img=100)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/hrnet/htc_hrnetv2p_w32_20e.py b/configs/hrnet/htc_hrnetv2p_w32_20e.py index b1f9ff567f7e2ecb94b89ee930585f41ddc96f37..8279f2457bb1c5037dd8b6308653cef06e3a83fa 100644 --- a/configs/hrnet/htc_hrnetv2p_w32_20e.py +++ b/configs/hrnet/htc_hrnetv2p_w32_20e.py @@ -207,8 +207,7 @@ test_cfg = dict( score_thr=0.001, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/htc/htc_dconv_c3-c5_mstrain_400_1400_x101_64x4d_fpn_20e.py b/configs/htc/htc_dconv_c3-c5_mstrain_400_1400_x101_64x4d_fpn_20e.py index f06904c531d6c1972a27c5f59bd0329610603914..2072f29bbbee4790f296574a658be4be375fb0aa 100644 --- a/configs/htc/htc_dconv_c3-c5_mstrain_400_1400_x101_64x4d_fpn_20e.py +++ b/configs/htc/htc_dconv_c3-c5_mstrain_400_1400_x101_64x4d_fpn_20e.py @@ -199,8 +199,7 @@ test_cfg = dict( score_thr=0.001, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/htc/htc_r101_fpn_20e.py b/configs/htc/htc_r101_fpn_20e.py index 36584a3db62f1573b83ad6dd2fc16c47914ef2da..661c564cb18503116ffb7bdf8ea6940b88f18b45 100644 --- a/configs/htc/htc_r101_fpn_20e.py +++ b/configs/htc/htc_r101_fpn_20e.py @@ -191,8 +191,7 @@ test_cfg = dict( score_thr=0.001, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/htc/htc_r50_fpn_1x.py b/configs/htc/htc_r50_fpn_1x.py index d77d60c7c9da85248cd271379ec268ff36e08ba4..4945f2ee6cb7178920ad1f7c682a396b87c7eed9 100644 --- a/configs/htc/htc_r50_fpn_1x.py +++ b/configs/htc/htc_r50_fpn_1x.py @@ -191,8 +191,7 @@ test_cfg = dict( score_thr=0.001, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/htc/htc_r50_fpn_20e.py b/configs/htc/htc_r50_fpn_20e.py index 9bc49afa39ce638488ae7bbe5b99042edc3b5abf..ccf73a08836f42bd576e7008382ba8e666130183 100644 --- a/configs/htc/htc_r50_fpn_20e.py +++ b/configs/htc/htc_r50_fpn_20e.py @@ -191,8 +191,7 @@ test_cfg = dict( score_thr=0.001, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/htc/htc_without_semantic_r50_fpn_1x.py b/configs/htc/htc_without_semantic_r50_fpn_1x.py index 2a4b7771274c952547f8dbc42f2878a1872a6bd8..de5dfcca6179065b8108d7d044ff2522bef026af 100644 --- a/configs/htc/htc_without_semantic_r50_fpn_1x.py +++ b/configs/htc/htc_without_semantic_r50_fpn_1x.py @@ -176,8 +176,7 @@ test_cfg = dict( score_thr=0.001, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/htc/htc_x101_32x4d_fpn_20e_16gpu.py b/configs/htc/htc_x101_32x4d_fpn_20e_16gpu.py index 21db137c842b399ce6a5d6fbceade6d38ec1bf01..915a54e532619b5650ecdc24af9108a6eeb2600f 100644 --- a/configs/htc/htc_x101_32x4d_fpn_20e_16gpu.py +++ b/configs/htc/htc_x101_32x4d_fpn_20e_16gpu.py @@ -193,8 +193,7 @@ test_cfg = dict( score_thr=0.001, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/configs/htc/htc_x101_64x4d_fpn_20e_16gpu.py b/configs/htc/htc_x101_64x4d_fpn_20e_16gpu.py index 6c5dada91b2976d66b5b0f581ef0a83cbf31739b..99ceefcab4dcafd2ea0d8b08b87152b95587d4bd 100644 --- a/configs/htc/htc_x101_64x4d_fpn_20e_16gpu.py +++ b/configs/htc/htc_x101_64x4d_fpn_20e_16gpu.py @@ -193,8 +193,7 @@ test_cfg = dict( score_thr=0.001, nms=dict(type='nms', iou_thr=0.5), max_per_img=100, - mask_thr_binary=0.5), - keep_all_stages=False) + mask_thr_binary=0.5)) # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' diff --git a/mmdet/models/detectors/cascade_rcnn.py b/mmdet/models/detectors/cascade_rcnn.py index 86e971b8c57cba0dd958f9ae8a445d54498319f1..e79b189d363140b2f769e1d5d4d4ac2d0132c4b5 100644 --- a/mmdet/models/detectors/cascade_rcnn.py +++ b/mmdet/models/detectors/cascade_rcnn.py @@ -339,41 +339,6 @@ class CascadeRCNN(BaseDetector, RPNTestMixin): cls_score, bbox_pred = bbox_head(bbox_feats) ms_scores.append(cls_score) - if self.test_cfg.keep_all_stages: - det_bboxes, det_labels = bbox_head.get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=rescale, - cfg=rcnn_test_cfg) - bbox_result = bbox2result(det_bboxes, det_labels, - bbox_head.num_classes) - ms_bbox_result['stage{}'.format(i)] = bbox_result - - if self.with_mask: - mask_roi_extractor = self.mask_roi_extractor[i] - mask_head = self.mask_head[i] - if det_bboxes.shape[0] == 0: - mask_classes = mask_head.num_classes - 1 - segm_result = [[] for _ in range(mask_classes)] - else: - _bboxes = ( - det_bboxes[:, :4] * - scale_factor if rescale else det_bboxes) - mask_rois = bbox2roi([_bboxes]) - mask_feats = mask_roi_extractor( - x[:len(mask_roi_extractor.featmap_strides)], - mask_rois) - if self.with_shared_head: - mask_feats = self.shared_head(mask_feats, i) - mask_pred = mask_head(mask_feats) - segm_result = mask_head.get_seg_masks( - mask_pred, _bboxes, det_labels, rcnn_test_cfg, - ori_shape, scale_factor, rescale) - ms_segm_result['stage{}'.format(i)] = segm_result - if i < self.num_stages - 1: bbox_label = cls_score.argmax(dim=1) rois = bbox_head.regress_by_class(rois, bbox_label, bbox_pred, @@ -425,20 +390,10 @@ class CascadeRCNN(BaseDetector, RPNTestMixin): ori_shape, scale_factor, rescale) ms_segm_result['ensemble'] = segm_result - if not self.test_cfg.keep_all_stages: - if self.with_mask: - results = (ms_bbox_result['ensemble'], - ms_segm_result['ensemble']) - else: - results = ms_bbox_result['ensemble'] + if self.with_mask: + results = (ms_bbox_result['ensemble'], ms_segm_result['ensemble']) else: - if self.with_mask: - results = { - stage: (ms_bbox_result[stage], ms_segm_result[stage]) - for stage in ms_bbox_result - } - else: - results = ms_bbox_result + results = ms_bbox_result['ensemble'] return results diff --git a/mmdet/models/detectors/htc.py b/mmdet/models/detectors/htc.py index 097d109ac488aefa71408c63c468f4163361fc1a..a989e17f03309348ee7707e53e9fc39e4de772ca 100644 --- a/mmdet/models/detectors/htc.py +++ b/mmdet/models/detectors/htc.py @@ -334,35 +334,6 @@ class HybridTaskCascade(CascadeRCNN): i, x, rois, semantic_feat=semantic_feat) ms_scores.append(cls_score) - if self.test_cfg.keep_all_stages: - det_bboxes, det_labels = bbox_head.get_det_bboxes( - rois, - cls_score, - bbox_pred, - img_shape, - scale_factor, - rescale=rescale, - cfg=rcnn_test_cfg) - bbox_result = bbox2result(det_bboxes, det_labels, - bbox_head.num_classes) - ms_bbox_result['stage{}'.format(i)] = bbox_result - - if self.with_mask: - mask_head = self.mask_head[i] - if det_bboxes.shape[0] == 0: - mask_classes = mask_head.num_classes - 1 - segm_result = [[] for _ in range(mask_classes)] - else: - _bboxes = ( - det_bboxes[:, :4] * - scale_factor if rescale else det_bboxes) - mask_pred = self._mask_forward_test( - i, x, _bboxes, semantic_feat=semantic_feat) - segm_result = mask_head.get_seg_masks( - mask_pred, _bboxes, det_labels, rcnn_test_cfg, - ori_shape, scale_factor, rescale) - ms_segm_result['stage{}'.format(i)] = segm_result - if i < self.num_stages - 1: bbox_label = cls_score.argmax(dim=1) rois = bbox_head.regress_by_class(rois, bbox_label, bbox_pred, @@ -415,20 +386,10 @@ class HybridTaskCascade(CascadeRCNN): ori_shape, scale_factor, rescale) ms_segm_result['ensemble'] = segm_result - if not self.test_cfg.keep_all_stages: - if self.with_mask: - results = (ms_bbox_result['ensemble'], - ms_segm_result['ensemble']) - else: - results = ms_bbox_result['ensemble'] + if self.with_mask: + results = (ms_bbox_result['ensemble'], ms_segm_result['ensemble']) else: - if self.with_mask: - results = { - stage: (ms_bbox_result[stage], ms_segm_result[stage]) - for stage in ms_bbox_result - } - else: - results = ms_bbox_result + results = ms_bbox_result['ensemble'] return results