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


Python roi_align.RoIAlignFunction方法代码示例

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


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

示例1: roi_feature_transform

# 需要导入模块: from modeling.roi_xfrom.roi_align.functions import roi_align [as 别名]
# 或者: from modeling.roi_xfrom.roi_align.functions.roi_align import RoIAlignFunction [as 别名]
def roi_feature_transform(self, blobs_in, rois, method='RoIPoolF',
                              resolution=7, spatial_scale=1. / 16., sampling_ratio=0):
        """Add the specified RoI pooling method. The sampling_ratio argument
        is supported for some, but not all, RoI transform methods.

        RoIFeatureTransform abstracts away:
          - Use of FPN or not
          - Specifics of the transform method
        """
        assert method in {'RoIPoolF', 'RoICrop', 'RoIAlign'}, \
            'Unknown pooling method: {}'.format(method)

        # Single feature level
        # rois: holds R regions of interest, each is a 5-tuple
        # (batch_idx, x1, y1, x2, y2) specifying an image batch index and a
        # rectangle (x1, y1, x2, y2)
        if method == 'RoIPoolF':
            xform_out = RoIPoolFunction(resolution, resolution, spatial_scale)(blobs_in, rois)
        elif method == 'RoICrop':
            grid_xy = net_utils.affine_grid_gen(rois, blobs_in.size()[2:], self.grid_size)
            grid_yx = torch.stack(
                [grid_xy.data[:, :, :, 1], grid_xy.data[:, :, :, 0]], 3).contiguous()
            xform_out = RoICropFunction()(blobs_in, Variable(grid_yx).detach())
            if cfg.CROP_RESIZE_WITH_MAX_POOL:
                xform_out = F.max_pool2d(xform_out, 2, 2)
        elif method == 'RoIAlign':
            xform_out = RoIAlignFunction(
                resolution, resolution, spatial_scale, sampling_ratio)(blobs_in, rois)

        return xform_out 
开发者ID:ppengtang,项目名称:pcl.pytorch,代码行数:32,代码来源:model_builder.py

示例2: crop_pose_map

# 需要导入模块: from modeling.roi_xfrom.roi_align.functions import roi_align [as 别名]
# 或者: from modeling.roi_xfrom.roi_align.functions.roi_align import RoIAlignFunction [as 别名]
def crop_pose_map(self, union_feats, part_boxes, flag, crop_size):
        triplets_num, part_num, _ = part_boxes.shape
        ret = torch.zeros((triplets_num, part_num, union_feats.shape[1], crop_size, crop_size)).cuda(
            union_feats.get_device())
        part_feats = RoIAlignFunction(crop_size, crop_size, self.spatial_scale, cfg.FAST_RCNN.ROI_XFORM_SAMPLING_RATIO)(
            union_feats, part_boxes.view(-1, part_boxes.shape[-1])).view(ret.shape)

        valid_n, valid_p = np.where(flag > 0)
        if len(valid_n) > 0:
            ret[valid_n, valid_p] = part_feats[valid_n, valid_p]
        return ret 
开发者ID:bobwan1995,项目名称:PMFNet,代码行数:13,代码来源:hoi.py


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