resnet_common.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:keras_experiments 作者: avolkov1 项目源码 文件源码
def _random_crop_and_resize_image(cls, image, bbox, height, width,
                                      val=False):
        with tf.name_scope('random_crop_and_resize'):
            if not val:
                # bbox_begin, bbox_size, distorted_bbox = \
                bbox_begin, bbox_size, _ = \
                    tf.image.sample_distorted_bounding_box(
                        tf.shape(image),
                        bounding_boxes=bbox,
                        min_object_covered=0.1,
                        aspect_ratio_range=[0.8, 1.25],
                        area_range=[0.1, 1.0],
                        max_attempts=100,
                        use_image_if_no_bounding_boxes=True)
                # Crop the image to the distorted bounding box
                image = tf.slice(image, bbox_begin, bbox_size)
            # Resize to the desired output size
            image = tf.image.resize_images(
                image,
                [height, width],
                tf.image.ResizeMethod.BILINEAR,
                align_corners=False)
            image.set_shape([height, width, 3])
            return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号