当前位置: 首页>>代码示例>>Python>>正文


Python fast_rcnn_heads.fast_rcnn_losses方法代码示例

本文整理汇总了Python中modeling.fast_rcnn_heads.fast_rcnn_losses方法的典型用法代码示例。如果您正苦于以下问题:Python fast_rcnn_heads.fast_rcnn_losses方法的具体用法?Python fast_rcnn_heads.fast_rcnn_losses怎么用?Python fast_rcnn_heads.fast_rcnn_losses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在modeling.fast_rcnn_heads的用法示例。


在下文中一共展示了fast_rcnn_heads.fast_rcnn_losses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from modeling import fast_rcnn_heads [as 别名]
# 或者: from modeling.fast_rcnn_heads import fast_rcnn_losses [as 别名]
def __init__(self, args):
        super(FRCNNCriterion3, self).__init__(args)

        # initialize Detectron
        this_dir = os.path.dirname(__file__)
        lib_path = os.path.join(this_dir, '../../external/Detectron.pytorch/')
        sys.path.insert(0, lib_path)
        from roi_data.rpn import add_rpn_blobs
        from modeling import rpn_heads, fast_rcnn_heads
        from core.config import cfg
        self.cfg = cfg
        self.add_rpn_blobs = add_rpn_blobs
        self.generic_rpn_losses = rpn_heads.generic_rpn_losses
        self.fast_rcnn_losses = fast_rcnn_heads.fast_rcnn_losses
        self.img_size = args.input_size
        self.nclass = args.nclass
        self.sigmoid = True 
开发者ID:gsig,项目名称:PyVideoResearch,代码行数:19,代码来源:frcnn_criterion3.py

示例2: forward

# 需要导入模块: from modeling import fast_rcnn_heads [as 别名]
# 或者: from modeling.fast_rcnn_heads import fast_rcnn_losses [as 别名]
def forward(self, score_predictions, roi_score, bbox_pred, rpn_ret, rpn_kwargs,
                target, meta, synchronous=False):

        # rpn loss
        loss_rpn_cls, loss_rpn_bbox = self.generic_rpn_losses(**rpn_kwargs)

        # bbox loss
        print('roi_score norm {} \t mean {}'.format(roi_score.norm(), roi_score.mean()))
        if self.training:
            if self.cfg.MODEL.CLS_AGNOSTIC_BBOX_REG:
                labels = rpn_ret['fix_labels_int32'].cpu().numpy() * rpn_ret['labels_int32'].cpu().numpy()
            else:
                labels = rpn_ret['labels_int32'].cpu().numpy()
            loss_cls, loss_bbox, accuracy_cls = self.fast_rcnn_losses(
                roi_score, bbox_pred, labels, rpn_ret['bbox_targets'].cpu().numpy(),
                rpn_ret['bbox_inside_weights'].cpu().numpy(), rpn_ret['bbox_outside_weights'].cpu().numpy())
        else:
            loss_cls = loss_bbox = accuracy_cls = 0

        if self.sigmoid:
            sigmoid_loss = torch.nn.MultiLabelSoftMarginLoss()
            loss_cls = sigmoid_loss(roi_score, rpn_ret['multilabels_int32'])
            print('sigmoid frcnn loss')

        losses = [loss_rpn_cls, loss_rpn_bbox*2, loss_cls*0, loss_bbox*0]
        print('losses {} {} {} {}'.format(*losses))
        print('accuracy {}'.format(accuracy_cls))

        score_targets = []
        for m in meta:
            score_targets.append({'boxes': m['boxes'],
                                  'labels': m['labels'],
                                  'start': m['start'],
                                  'vid': m['id']})

        return score_predictions, sum(losses), score_targets 
开发者ID:gsig,项目名称:PyVideoResearch,代码行数:38,代码来源:frcnn_criterion3.py


注:本文中的modeling.fast_rcnn_heads.fast_rcnn_losses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。