image_reader_classfc.py 文件源码

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

项目:dcsp_segmentation 作者: arslan-chaudhry 项目源码 文件源码
def random_crop_and_pad_image_and_labels(image, crop_h, crop_w, seed):
    """
    Randomly crop and pads the input images.

    Args:
      image: Training image to crop/ pad.
      crop_h: Height of cropped segment.
      crop_w: Width of cropped segment.
      seed: Random seed.
    """

    image_shape = tf.shape(image)
    img_pad = tf.image.pad_to_bounding_box(image, 0, 0, tf.maximum(crop_h, image_shape[0]), tf.maximum(crop_w, image_shape[1]))

    img_crop = tf.random_crop(img_pad, [crop_h,crop_w,3], seed=seed)

    # Set static shape so that tensorflow knows shape at compile time.
    img_crop.set_shape((crop_h, crop_w, 3))
    return img_crop
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号