def forward(self, feats):
    fam_reg_branch_list = []
    fam_cls_branch_list = []
    odm_reg_branch_list = []
    odm_cls_branch_list = []
    self.featmap_sizes_list = []
    self.base_anchors_list = []
    self.refine_anchor_list = []
    for feat_idx in range(len(feats)):
        feat = feats[feat_idx]
        fam_cls_feat = self.fam_cls_convs(feat)
        fam_cls = self.fam_cls(fam_cls_feat)
        fam_cls = fam_cls.transpose([0, 2, 3, 1])
        fam_cls_reshape = paddle.reshape(fam_cls, [fam_cls.shape[0], (- 1), self.cls_out_channels])
        fam_cls_branch_list.append(fam_cls_reshape)
        fam_reg_feat = self.fam_reg_convs(feat)
        fam_reg = self.fam_reg(fam_reg_feat)
        fam_reg = fam_reg.transpose([0, 2, 3, 1])
        fam_reg_reshape = paddle.reshape(fam_reg, [fam_reg.shape[0], (- 1), 5])
        fam_reg_branch_list.append(fam_reg_reshape)
        featmap_size = (paddle.shape(feat)[2], paddle.shape(feat)[3])
        self.featmap_sizes_list.append(featmap_size)
        init_anchors = self.anchor_generators[feat_idx](featmap_size, self.anchor_strides[feat_idx])
        init_anchors = paddle.to_tensor(init_anchors, dtype='float32')
        NA = (featmap_size[0] * featmap_size[1])
        init_anchors = paddle.reshape(init_anchors, [NA, 4])
        init_anchors = self.rect2rbox(init_anchors)
        self.base_anchors_list.append(init_anchors)
        if self.training:
            refine_anchor = self.bbox_decode(fam_reg.detach(), init_anchors)
        else:
            refine_anchor = self.bbox_decode(fam_reg, init_anchors)
        self.refine_anchor_list.append(refine_anchor)
        if (self.align_conv_type == 'AlignConv'):
            align_feat = self.align_conv(feat, refine_anchor.clone(), featmap_size, self.anchor_strides[feat_idx])
        elif (self.align_conv_type == 'DCN'):
            align_offset = self.align_conv_offset(feat)
            align_feat = self.align_conv(feat, align_offset)
        elif (self.align_conv_type == 'Conv'):
            align_feat = self.align_conv(feat)
        or_feat = self.or_conv(align_feat)
        odm_reg_feat = or_feat
        odm_cls_feat = or_feat
        odm_reg_feat = self.odm_reg_convs(odm_reg_feat)
        odm_cls_feat = self.odm_cls_convs(odm_cls_feat)
        odm_cls_score = self.odm_cls(odm_cls_feat)
        odm_cls_score = odm_cls_score.transpose([0, 2, 3, 1])
        odm_cls_score_shape = odm_cls_score.shape
        odm_cls_score_reshape = paddle.reshape(odm_cls_score, [odm_cls_score_shape[0], (odm_cls_score_shape[1] * odm_cls_score_shape[2]), self.cls_out_channels])
        odm_cls_branch_list.append(odm_cls_score_reshape)
        odm_bbox_pred = self.odm_reg(odm_reg_feat)
        odm_bbox_pred = odm_bbox_pred.transpose([0, 2, 3, 1])
        odm_bbox_pred_reshape = paddle.reshape(odm_bbox_pred, [(- 1), 5])
        odm_bbox_pred_reshape = paddle.unsqueeze(odm_bbox_pred_reshape, axis=0)
        odm_reg_branch_list.append(odm_bbox_pred_reshape)
    self.s2anet_head_out = (fam_cls_branch_list, fam_reg_branch_list, odm_cls_branch_list, odm_reg_branch_list)
    return self.s2anet_head_out
def forward(self, feats):
    fam_reg_branch_list = []
    fam_cls_branch_list = []
    odm_reg_branch_list = []
    odm_cls_branch_list = []
    self.featmap_sizes_list = []
    self.base_anchors_list = []
    self.refine_anchor_list = []
    for feat_idx in range(len(feats)):
        feat = feats[feat_idx]
        fam_cls_feat = self.fam_cls_convs(feat)
        fam_cls = self.fam_cls(fam_cls_feat)
        fam_cls = fam_cls.transpose([0, 2, 3, 1])
        fam_cls_reshape = paddle.reshape(fam_cls, [fam_cls.shape[0], (- 1), self.cls_out_channels])
        fam_cls_branch_list.append(fam_cls_reshape)
        fam_reg_feat = self.fam_reg_convs(feat)
        fam_reg = self.fam_reg(fam_reg_feat)
        fam_reg = fam_reg.transpose([0, 2, 3, 1])
        fam_reg_reshape = paddle.reshape(fam_reg, [fam_reg.shape[0], (- 1), 5])
        fam_reg_branch_list.append(fam_reg_reshape)
        featmap_size = (paddle.shape(feat)[2], paddle.shape(feat)[3])
        self.featmap_sizes_list.append(featmap_size)
        init_anchors = self.anchor_generators[feat_idx](featmap_size, self.anchor_strides[feat_idx])
        init_anchors = paddle.to_tensor(init_anchors, dtype='float32')
        NA = (featmap_size[0] * featmap_size[1])
        init_anchors = paddle.reshape(init_anchors, [NA, 4])
        init_anchors = self.rect2rbox(init_anchors)
        self.base_anchors_list.append(init_anchors)
        if self.training:
            refine_anchor = self.bbox_decode(fam_reg.detach(), init_anchors)
        else:
            refine_anchor = self.bbox_decode(fam_reg, init_anchors)
        self.refine_anchor_list.append(refine_anchor)
        if (self.align_conv_type == 'AlignConv'):
            align_feat = self.align_conv(feat, refine_anchor.clone(), featmap_size, self.anchor_strides[feat_idx])
        elif (self.align_conv_type == 'DCN'):
            align_offset = self.align_conv_offset(feat)
            align_feat = self.align_conv(feat, align_offset)
        elif (self.align_conv_type == 'Conv'):
            align_feat = self.align_conv(feat)
        or_feat = self.or_conv(align_feat)
        odm_reg_feat = or_feat
        odm_cls_feat = or_feat
        odm_reg_feat = self.odm_reg_convs(odm_reg_feat)
        odm_cls_feat = self.odm_cls_convs(odm_cls_feat)
        odm_cls_score = self.odm_cls(odm_cls_feat)
        odm_cls_score = odm_cls_score.transpose([0, 2, 3, 1])
        odm_cls_score_shape = odm_cls_score.shape
        odm_cls_score_reshape = paddle.reshape(odm_cls_score, [odm_cls_score_shape[0], (odm_cls_score_shape[1] * odm_cls_score_shape[2]), self.cls_out_channels])
        odm_cls_branch_list.append(odm_cls_score_reshape)
        odm_bbox_pred = self.odm_reg(odm_reg_feat)
        odm_bbox_pred = odm_bbox_pred.transpose([0, 2, 3, 1])
        odm_bbox_pred_reshape = paddle.reshape(odm_bbox_pred, [(- 1), 5])
        odm_bbox_pred_reshape = paddle.unsqueeze(odm_bbox_pred_reshape, axis=0)
        odm_reg_branch_list.append(odm_bbox_pred_reshape)
    self.s2anet_head_out = (fam_cls_branch_list, fam_reg_branch_list, odm_cls_branch_list, odm_reg_branch_list)
    return self.s2anet_head_out