Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
type='DetDataPreprocessor',
mean=[103.530, 116.280, 123.675],
std=[57.375, 57.120, 58.395],
to_rgb=False,
bgr_to_rgb=False,
pad_size_divisor=32),
backbone=dict(
type='ResNeXt',
Expand Down
2 changes: 1 addition & 1 deletion configs/cascade_rcnn/cascade-rcnn_r50-caffe_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type='DetDataPreprocessor',
mean=[103.530, 116.280, 123.675],
std=[1.0, 1.0, 1.0],
to_rgb=False,
bgr_to_rgb=False,
pad_size_divisor=32),
backbone=dict(
norm_cfg=dict(requires_grad=False),
Expand Down
10 changes: 5 additions & 5 deletions configs/dcnv2/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Collections:
Models:
- Name: faster-rcnn_r50_fpn_mdconv_c3-c5_1x_coco
In Collection: Deformable Convolutional Networks v2
Config: configs/dcn/faster-rcnn_r50-mdconv-c3-c5_fpn_1x_coco.py
Config: configs/dcnv2/faster-rcnn_r50-mdconv-c3-c5_fpn_1x_coco.py
Metadata:
Training Memory (GB): 4.1
inference time (ms/im):
Expand All @@ -39,7 +39,7 @@ Models:

- Name: faster-rcnn_r50_fpn_mdconv_c3-c5_group4_1x_coco
In Collection: Deformable Convolutional Networks v2
Config: configs/dcn/faster-rcnn_r50-mdconv-group4-c3-c5_fpn_1x_coco.py
Config: configs/dcnv2/faster-rcnn_r50-mdconv-group4-c3-c5_fpn_1x_coco.py
Metadata:
Training Memory (GB): 4.2
inference time (ms/im):
Expand All @@ -59,7 +59,7 @@ Models:

- Name: faster-rcnn_r50_fpn_mdpool_1x_coco
In Collection: Deformable Convolutional Networks v2
Config: configs/dcn/faster-rcnn_r50_fpn_mdpool_1x_coco.py
Config: configs/dcnv2/faster-rcnn_r50_fpn_mdpool_1x_coco.py
Metadata:
Training Memory (GB): 5.8
inference time (ms/im):
Expand All @@ -79,7 +79,7 @@ Models:

- Name: mask-rcnn_r50_fpn_mdconv_c3-c5_1x_coco
In Collection: Deformable Convolutional Networks v2
Config: configs/dcn/mask-rcnn_r50-mdconv-c3-c5_fpn_1x_coco.py
Config: configs/dcnv2/mask-rcnn_r50-mdconv-c3-c5_fpn_1x_coco.py
Metadata:
Training Memory (GB): 4.5
inference time (ms/im):
Expand All @@ -103,7 +103,7 @@ Models:

- Name: mask-rcnn_r50_fpn_fp16_mdconv_c3-c5_1x_coco
In Collection: Deformable Convolutional Networks v2
Config: configs/dcn/mask-rcnn_r50-mdconv-c3-c5_fpn_amp-1x_coco.py
Config: configs/dcnv2/mask-rcnn_r50-mdconv-c3-c5_fpn_amp-1x_coco.py
Metadata:
Training Memory (GB): 3.1
Training Techniques:
Expand Down
15 changes: 13 additions & 2 deletions configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
_base_ = ['./mask2former_r50_8xb2-lsj-50e_coco-panoptic.py']

num_things_classes = 80
num_stuff_classes = 0
num_classes = num_things_classes + num_stuff_classes
Expand Down Expand Up @@ -56,6 +55,17 @@
dict(type='PackDetInputs')
]

test_pipeline = [
dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args),
dict(type='Resize', scale=(1333, 800), keep_ratio=True),
# If you don't have a gt annotation, delete the pipeline
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
dict(
type='PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]

dataset_type = 'CocoDataset'
data_root = 'data/coco/'

Expand All @@ -70,7 +80,8 @@
dataset=dict(
type=dataset_type,
ann_file='annotations/instances_val2017.json',
data_prefix=dict(img='val2017/')))
data_prefix=dict(img='val2017/'),
pipeline=test_pipeline))
test_dataloader = val_dataloader

val_evaluator = dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
dataset=dict(
type=dataset_type,
ann_file='challenge2019/challenge-2019-validation-detection-bbox.txt',
data_prefix=dict(img='OpenImages/'),
label_file='challenge2019/cls-label-description.csv',
hierarchy_file='challenge2019/class_label_tree.np',
meta_file='challenge2019/challenge-2019-validation-metas.pkl',
Expand Down
7 changes: 5 additions & 2 deletions configs/retinanet/retinanet_r101-caffe_fpn_ms-3x_coco.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
_base_ = './retinanet_r50-caffe_fpn_ms-3x_coco.py'
# learning policy
model = dict(
pretrained='open-mmlab://detectron2/resnet101_caffe',
backbone=dict(depth=101))
backbone=dict(
depth=101,
init_cfg=dict(
type='Pretrained',
checkpoint='open-mmlab://detectron2/resnet101_caffe')))
6 changes: 5 additions & 1 deletion configs/retinanet/retinanet_r101_fpn_ms-640-800-3x_coco.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
_base_ = ['../_base_/models/retinanet_r50_fpn.py', '../common/ms_3x_coco.py']
# optimizer
model = dict(pretrained='torchvision://resnet101', backbone=dict(depth=101))
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained',
checkpoint='torchvision://resnet101')))
optim_wrapper = dict(
optimizer=dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001))
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
_base_ = ['../_base_/models/retinanet_r50_fpn.py', '../common/ms_3x_coco.py']
# optimizer
model = dict(
pretrained='open-mmlab://resnext101_64x4d',
backbone=dict(type='ResNeXt', depth=101, groups=64, base_width=4))
backbone=dict(
type='ResNeXt',
depth=101,
groups=64,
base_width=4,
init_cfg=dict(
type='Pretrained', checkpoint='open-mmlab://resnext101_64x4d')))
optim_wrapper = dict(optimizer=dict(type='SGD', lr=0.01))
8 changes: 4 additions & 4 deletions configs/seesaw_loss/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Collections:
Models:
- Name: mask-rcnn_r50_fpn_random_seesaw_loss_mstrain_2x_lvis_v1
In Collection: Seesaw Loss
Config: seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_random-ms-2x_lvis-v1.py
Config: configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_random-ms-2x_lvis-v1.py
Metadata:
Epochs: 24
Results:
Expand All @@ -38,7 +38,7 @@ Models:
Weights: https://download.openmmlab.com/mmdetection/v2.0/seesaw_loss/mask_rcnn_r50_fpn_random_seesaw_loss_mstrain_2x_lvis_v1-a698dd3d.pth
- Name: mask-rcnn_r50_fpn_random_seesaw_loss_normed_mask_mstrain_2x_lvis_v1
In Collection: Seesaw Loss
Config: seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss-normed-mask_random-ms-2x_lvis-v1.py
Config: configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss-normed-mask_random-ms-2x_lvis-v1.py
Metadata:
Epochs: 24
Results:
Expand All @@ -53,7 +53,7 @@ Models:
Weights: https://download.openmmlab.com/mmdetection/v2.0/seesaw_loss/mask_rcnn_r50_fpn_random_seesaw_loss_normed_mask_mstrain_2x_lvis_v1-a1c11314.pth
- Name: mask-rcnn_r101_fpn_seesaw-loss_random-ms-2x_lvis-v1
In Collection: Seesaw Loss
Config: seesaw_loss/mask-rcnn_r101_fpn_seesaw-loss_random-ms-2x_lvis-v1.py
Config: configs/seesaw_loss/mask-rcnn_r101_fpn_seesaw-loss_random-ms-2x_lvis-v1.py
Metadata:
Epochs: 24
Results:
Expand All @@ -68,7 +68,7 @@ Models:
Weights: https://download.openmmlab.com/mmdetection/v2.0/seesaw_loss/mask_rcnn_r101_fpn_random_seesaw_loss_mstrain_2x_lvis_v1-8e6e6dd5.pth
- Name: mask-rcnn_r101_fpn_seesaw-loss-normed-mask_random-ms-2x_lvis-v1
In Collection: Seesaw Loss
Config: seesaw_loss/mask-rcnn_r101_fpn_seesaw-loss-normed-mask_random-ms-2x_lvis-v1.py
Config: configs/seesaw_loss/mask-rcnn_r101_fpn_seesaw-loss-normed-mask_random-ms-2x_lvis-v1.py
Metadata:
Epochs: 24
Results:
Expand Down
3 changes: 1 addition & 2 deletions mmdet/models/dense_heads/deformable_detr_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ def forward(self, x: Tuple[Tensor],
enc_outputs_class, \
enc_outputs_coord.sigmoid()
else:
return outputs_classes, outputs_coords, \
None, None
return outputs_classes, outputs_coords

def loss_by_feat(
self,
Expand Down
26 changes: 26 additions & 0 deletions mmdet/models/detectors/detr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from typing import List, Tuple

from torch import Tensor

from mmdet.registry import MODELS
from mmdet.structures import SampleList
from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig
from .single_stage import SingleStageDetector

Expand All @@ -24,3 +29,24 @@ def __init__(self,
test_cfg=test_cfg,
data_preprocessor=data_preprocessor,
init_cfg=init_cfg)

def _forward(self, batch_inputs: Tensor,
batch_data_samples: SampleList) -> Tuple[List[Tensor]]:
"""Network forward process. Usually includes backbone, neck and head
forward without any post-processing.

Args:
batch_inputs (Tensor): Inputs with shape (N, C, H, W).
batch_data_samples (list[:obj:`DetDataSample`]): The batch
data samples. It usually includes information such
as `gt_instance` or `gt_panoptic_seg` or `gt_sem_seg`.

Returns:
tuple[list]: A tuple of features from ``bbox_head`` forward.
"""
x = self.extract_feat(batch_inputs)
batch_img_metas = [
data_samples.metainfo for data_samples in batch_data_samples
]
results = self.bbox_head.forward(x, batch_img_metas)
return results
3 changes: 3 additions & 0 deletions mmdet/models/detectors/single_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def _forward(

Args:
batch_inputs (Tensor): Inputs with shape (N, C, H, W).
batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
the meta information of each image and corresponding
annotations.

Returns:
tuple[list]: A tuple of features from ``bbox_head`` forward.
Expand Down
7 changes: 5 additions & 2 deletions mmdet/models/detectors/two_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def _forward(self, batch_inputs: Tensor,

Args:
batch_inputs (Tensor): Inputs with shape (N, C, H, W).
batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
the meta information of each image and corresponding
annotations.

Returns:
tuple: A tuple of features from ``rpn_head`` and ``roi_head``
Expand All @@ -135,8 +138,8 @@ def _forward(self, batch_inputs: Tensor,
rpn_results_list = [
data_sample.proposals for data_sample in batch_data_samples
]

roi_outs = self.roi_head.forward(x, rpn_results_list)
roi_outs = self.roi_head.forward(x, rpn_results_list,
batch_data_samples)
results = results + (roi_outs, )
return results

Expand Down
48 changes: 48 additions & 0 deletions mmdet/models/roi_heads/cascade_roi_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,51 @@ def _refine_roi(self, x: Tuple[Tensor], rois: Tensor,
for i in range(len(batch_img_metas))
]
return rois, cls_scores, bbox_preds

def forward(self, x: Tuple[Tensor], rpn_results_list: InstanceList,
batch_data_samples: SampleList) -> tuple:
"""Network forward process. Usually includes backbone, neck and head
forward without any post-processing.

Args:
x (List[Tensor]): Multi-level features that may have different
resolutions.
rpn_results_list (list[:obj:`InstanceData`]): List of region
proposals.
batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
the meta information of each image and corresponding
annotations.

Returns
tuple: A tuple of features from ``bbox_head`` and ``mask_head``
forward.
"""
results = ()
batch_img_metas = [
data_samples.metainfo for data_samples in batch_data_samples
]
proposals = [rpn_results.bboxes for rpn_results in rpn_results_list]
num_proposals_per_img = tuple(len(p) for p in proposals)
rois = bbox2roi(proposals)
# bbox head
if self.with_bbox:
rois, cls_scores, bbox_preds = self._refine_roi(
x, rois, batch_img_metas, num_proposals_per_img)
results = results + (cls_scores, bbox_preds)
# mask head
if self.with_mask:
aug_masks = []
rois = torch.cat(rois)
for stage in range(self.num_stages):
mask_results = self._mask_forward(stage, x, rois)
mask_preds = mask_results['mask_preds']
mask_preds = mask_preds.split(num_proposals_per_img, 0)
aug_masks.append([m.sigmoid().detach() for m in mask_preds])

merged_masks = []
for i in range(len(batch_img_metas)):
aug_mask = [mask[i] for mask in aug_masks]
merged_mask = merge_aug_masks(aug_mask, batch_img_metas[i])
merged_masks.append(merged_mask)
results = results + (merged_masks, )
return results
14 changes: 10 additions & 4 deletions mmdet/models/roi_heads/grid_roi_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ def _random_jitter(self,
return sampling_results

# TODO: Forward is incorrect and need to refactor.
def forward(self, x: Tuple[Tensor],
rpn_results_list: InstanceList) -> tuple:
def forward(self,
x: Tuple[Tensor],
rpn_results_list: InstanceList,
batch_data_samples: SampleList = None) -> tuple:
"""Network forward process. Usually includes backbone, neck and head
forward without any post-processing.

Expand All @@ -85,6 +87,9 @@ def forward(self, x: Tuple[Tensor],
resolutions.
rpn_results_list (list[:obj:`InstanceData`]): List of region
proposals.
batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
the meta information of each image and corresponding
annotations.

Returns
tuple: A tuple of features from ``bbox_head`` and ``mask_head``
Expand All @@ -96,8 +101,9 @@ def forward(self, x: Tuple[Tensor],
# bbox head
if self.with_bbox:
bbox_results = self._bbox_forward(x, rois)
results = results + (bbox_results['cls_score'],
bbox_results['bbox_pred'])
results = results + (bbox_results['cls_score'], )
if self.bbox_head.with_reg:
results = results + (bbox_results['bbox_pred'], )

# grid head
grid_rois = rois[:100]
Expand Down
Loading