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


Python tensorflow.crop_and_resize方法代码示例

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


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

示例1: reorder_projected_boxes

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import crop_and_resize [as 别名]
def reorder_projected_boxes(box_corners):
    """Helper function to reorder image corners.

    This reorders the corners from [x1, y1, x2, y2] to
    [y1, x1, y2, x2] which is required by the tf.crop_and_resize op.

    Args:
        box_corners: tensor image corners in the format
            N x [x1, y1, x2, y2]

    Returns:
        box_corners_reordered: tensor image corners in the format
            N x [y1, x1, y2, x2]
    """
    boxes_reordered = tf.stack([box_corners[:, 1],
                                box_corners[:, 0],
                                box_corners[:, 3],
                                box_corners[:, 2]],
                               axis=1)
    return boxes_reordered 
开发者ID:kujason,项目名称:avod,代码行数:22,代码来源:anchor_projector.py

示例2: _roi_crop

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import crop_and_resize [as 别名]
def _roi_crop(self, roi_proposals, conv_feature_map, im_shape):
        # Get normalized bounding boxes.
        bboxes = self._get_bboxes(roi_proposals, im_shape)
        # Generate fake batch ids
        bboxes_shape = tf.shape(bboxes)
        batch_ids = tf.zeros((bboxes_shape[0], ), dtype=tf.int32)
        # Apply crop and resize with extracting a crop double the desired size.
        crops = tf.image.crop_and_resize(
            conv_feature_map, bboxes, batch_ids,
            [self._pooled_width * 2, self._pooled_height * 2], name="crops"
        )

        # Applies max pool with [2,2] kernel to reduce the crops to half the
        # size, and thus having the desired output.
        prediction_dict = {
            'roi_pool': tf.nn.max_pool(
                crops, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1],
                padding=self._pooled_padding
            ),
        }

        if self._debug:
            prediction_dict['bboxes'] = bboxes
            prediction_dict['crops'] = crops
            prediction_dict['batch_ids'] = batch_ids
            prediction_dict['conv_feature_map'] = conv_feature_map

        return prediction_dict 
开发者ID:Sargunan,项目名称:Table-Detection-using-Deep-learning,代码行数:30,代码来源:roi_pool.py


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