diff --git a/ppdet/modeling/heads/mask_head.py b/ppdet/modeling/heads/mask_head.py index 939debbaae129293551394b5571f7da158a0cccb..403d4ceebcf676f9c55c666e2969a33be5816e9c 100644 --- a/ppdet/modeling/heads/mask_head.py +++ b/ppdet/modeling/heads/mask_head.py @@ -80,7 +80,7 @@ class MaskFeat(nn.Layer): mask_conv.add_sublayer( 'conv5_mask', nn.Conv2DTranspose( - in_channels=self.in_channel, + in_channels=self.out_channel if num_convs > 0 else self.in_channel, out_channels=self.out_channel, kernel_size=2, stride=2, diff --git a/ppdet/modeling/heads/sparsercnn_head.py b/ppdet/modeling/heads/sparsercnn_head.py index 377cf27fc6e10ff62b06345c7f639f064c05e5e7..801ff04fb772aec568dd94d9d4916d2b778e88fe 100644 --- a/ppdet/modeling/heads/sparsercnn_head.py +++ b/ppdet/modeling/heads/sparsercnn_head.py @@ -242,6 +242,8 @@ class SparseRCNNHead(nn.Layer): loss_func="SparseRCNNLoss", roi_input_shape=None, ): super().__init__() + assert head_num_heads > 0, \ + f'At least one RoI Head is required, but {head_num_heads}.' # Build RoI. box_pooler = self._init_box_pooler(roi_input_shape) @@ -337,11 +339,11 @@ class SparseRCNNHead(nn.Layer): inter_class_logits = [] inter_pred_bboxes = [] - for rcnn_head in self.head_series: + for stage, rcnn_head in enumerate(self.head_series): class_logits, pred_bboxes, proposal_features = rcnn_head( features, bboxes, proposal_features, self.box_pooler) - if self.return_intermediate: + if self.return_intermediate or stage == len(self.head_series) - 1: inter_class_logits.append(class_logits) inter_pred_bboxes.append(pred_bboxes) bboxes = pred_bboxes.detach()