mscoco_segnet_input.py 文件源码

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

项目:woipv 作者: Panaetius 项目源码 文件源码
def random_crop_and_pad_image_and_labels(self, image, labels, size):
        """Randomly crops `image` together with `labels`.

        Args:
            image: A Tensor with shape [D_1, ..., D_K, N]
            labels: A Tensor with shape [D_1, ..., D_K, M]
            size: A Tensor with shape [K] indicating the crop size.
        Returns:
            A tuple of (cropped_image, cropped_label).
        """
        combined = tf.concat([image, labels], axis=2)
        image_shape = tf.shape(image)
        combined_pad = tf.image.pad_to_bounding_box(
            combined, 0, 0,
            tf.maximum(size[0], image_shape[0]),
            tf.maximum(size[1], image_shape[1]))
        last_label_dim = tf.shape(labels)[-1]
        last_image_dim = tf.shape(image)[-1]
        combined_crop = tf.random_crop(
            combined_pad,
            size=tf.concat([size, [last_label_dim + last_image_dim]],
                            axis=0))
        return (combined_crop[:, :, :last_image_dim],
                combined_crop[:, :, last_image_dim:])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号