當前位置: 首頁>>代碼示例>>Python>>正文


Python cfg.CROP_RESIZE_WITH_MAX_POOL屬性代碼示例

本文整理匯總了Python中core.config.cfg.CROP_RESIZE_WITH_MAX_POOL屬性的典型用法代碼示例。如果您正苦於以下問題:Python cfg.CROP_RESIZE_WITH_MAX_POOL屬性的具體用法?Python cfg.CROP_RESIZE_WITH_MAX_POOL怎麽用?Python cfg.CROP_RESIZE_WITH_MAX_POOL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在core.config.cfg的用法示例。


在下文中一共展示了cfg.CROP_RESIZE_WITH_MAX_POOL屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: roi_feature_transform

# 需要導入模塊: from core.config import cfg [as 別名]
# 或者: from core.config.cfg import CROP_RESIZE_WITH_MAX_POOL [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


注:本文中的core.config.cfg.CROP_RESIZE_WITH_MAX_POOL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。