From 93de5e5fcb4d77c0a9767cfd5d22fb2aa990efb8 Mon Sep 17 00:00:00 2001 From: ucsk <53417456+ucsk@users.noreply.github.com> Date: Thu, 8 Dec 2022 12:00:20 +0800 Subject: [PATCH] fix 2 bugs (#7409) * fix transposed convolution in_channels * fix when deep_supervision is false --- ppdet/modeling/heads/mask_head.py | 2 +- ppdet/modeling/heads/sparsercnn_head.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ppdet/modeling/heads/mask_head.py b/ppdet/modeling/heads/mask_head.py index 939debbaa..403d4ceeb 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 377cf27fc..801ff04fb 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() -- GitLab