def get_loss(self, inputs):
    fam_cls_loss_lst = []
    fam_reg_loss_lst = []
    odm_cls_loss_lst = []
    odm_reg_loss_lst = []
    im_shape = inputs['im_shape']
    for im_id in range(im_shape.shape[0]):
        np_im_shape = inputs['im_shape'][im_id].numpy()
        np_scale_factor = inputs['scale_factor'][im_id].numpy()
        gt_bboxes = inputs['gt_rbox'][im_id].numpy()
        gt_labels = inputs['gt_class'][im_id].numpy()
        is_crowd = inputs['is_crowd'][im_id].numpy()
        gt_labels = (gt_labels + 1)
        anchors_list_all = np.concatenate(self.base_anchors_list)
        fam_cls_feats_list = [e[im_id] for e in self.s2anet_head_out[0]]
        fam_reg_feats_list = [e[im_id] for e in self.s2anet_head_out[1]]
        odm_cls_feats_list = [e[im_id] for e in self.s2anet_head_out[2]]
        odm_reg_feats_list = [e[im_id] for e in self.s2anet_head_out[3]]
        im_s2anet_head_out = (fam_cls_feats_list, fam_reg_feats_list, odm_cls_feats_list, odm_reg_feats_list)
        im_fam_target = self.anchor_assign(anchors_list_all, gt_bboxes, gt_labels, is_crowd)
        if (im_fam_target is not None):
            (im_fam_cls_loss, im_fam_reg_loss) = self.get_fam_loss(im_fam_target, im_s2anet_head_out, self.reg_loss_type)
            fam_cls_loss_lst.append(im_fam_cls_loss)
            fam_reg_loss_lst.append(im_fam_reg_loss)
        np_refine_anchors_list = paddle.concat(self.refine_anchor_list).numpy()
        np_refine_anchors_list = np.concatenate(np_refine_anchors_list)
        np_refine_anchors_list = np_refine_anchors_list.reshape((- 1), 5)
        im_odm_target = self.anchor_assign(np_refine_anchors_list, gt_bboxes, gt_labels, is_crowd)
        if (im_odm_target is not None):
            (im_odm_cls_loss, im_odm_reg_loss) = self.get_odm_loss(im_odm_target, im_s2anet_head_out, self.reg_loss_type)
            odm_cls_loss_lst.append(im_odm_cls_loss)
            odm_reg_loss_lst.append(im_odm_reg_loss)
    fam_cls_loss = paddle.add_n(fam_cls_loss_lst)
    fam_reg_loss = paddle.add_n(fam_reg_loss_lst)
    odm_cls_loss = paddle.add_n(odm_cls_loss_lst)
    odm_reg_loss = paddle.add_n(odm_reg_loss_lst)
    return {'fam_cls_loss': fam_cls_loss, 'fam_reg_loss': fam_reg_loss, 'odm_cls_loss': odm_cls_loss, 'odm_reg_loss': odm_reg_loss}
def get_loss(self, inputs):
    fam_cls_loss_lst = []
    fam_reg_loss_lst = []
    odm_cls_loss_lst = []
    odm_reg_loss_lst = []
    im_shape = inputs['im_shape']
    for im_id in range(im_shape.shape[0]):
        np_im_shape = inputs['im_shape'][im_id].numpy()
        np_scale_factor = inputs['scale_factor'][im_id].numpy()
        gt_bboxes = inputs['gt_rbox'][im_id].numpy()
        gt_labels = inputs['gt_class'][im_id].numpy()
        is_crowd = inputs['is_crowd'][im_id].numpy()
        gt_labels = (gt_labels + 1)
        anchors_list_all = np.concatenate(self.base_anchors_list)
        fam_cls_feats_list = [e[im_id] for e in self.s2anet_head_out[0]]
        fam_reg_feats_list = [e[im_id] for e in self.s2anet_head_out[1]]
        odm_cls_feats_list = [e[im_id] for e in self.s2anet_head_out[2]]
        odm_reg_feats_list = [e[im_id] for e in self.s2anet_head_out[3]]
        im_s2anet_head_out = (fam_cls_feats_list, fam_reg_feats_list, odm_cls_feats_list, odm_reg_feats_list)
        im_fam_target = self.anchor_assign(anchors_list_all, gt_bboxes, gt_labels, is_crowd)
        if (im_fam_target is not None):
            (im_fam_cls_loss, im_fam_reg_loss) = self.get_fam_loss(im_fam_target, im_s2anet_head_out, self.reg_loss_type)
            fam_cls_loss_lst.append(im_fam_cls_loss)
            fam_reg_loss_lst.append(im_fam_reg_loss)
        np_refine_anchors_list = paddle.concat(self.refine_anchor_list).numpy()
        np_refine_anchors_list = np.concatenate(np_refine_anchors_list)
        np_refine_anchors_list = np_refine_anchors_list.reshape((- 1), 5)
        im_odm_target = self.anchor_assign(np_refine_anchors_list, gt_bboxes, gt_labels, is_crowd)
        if (im_odm_target is not None):
            (im_odm_cls_loss, im_odm_reg_loss) = self.get_odm_loss(im_odm_target, im_s2anet_head_out, self.reg_loss_type)
            odm_cls_loss_lst.append(im_odm_cls_loss)
            odm_reg_loss_lst.append(im_odm_reg_loss)
    fam_cls_loss = paddle.add_n(fam_cls_loss_lst)
    fam_reg_loss = paddle.add_n(fam_reg_loss_lst)
    odm_cls_loss = paddle.add_n(odm_cls_loss_lst)
    odm_reg_loss = paddle.add_n(odm_reg_loss_lst)
    return {'fam_cls_loss': fam_cls_loss, 'fam_reg_loss': fam_reg_loss, 'odm_cls_loss': odm_cls_loss, 'odm_reg_loss': odm_reg_loss}