def transpose(images):
"""Transpose an image/images by swapping the first and second dimension.
(A mirror to tf.image transpose_image)
Args:
images: 4-D Tensor of shape `[batch, height, width, channels]` or
3-D Tensor of shape `[height, width, channels]`.
Returns:
If `image` was 4-D, a 4-D float Tensor of shape
`[batch, target_height, target_width, channels]`
If `image` was 3-D, a 3-D float Tensor of shape
`[target_height, target_width, channels]
Raises:
ValueError: if the shape of `image` not supported.
"""
images_shape = get_shape(images)
if len(images_shape) > 4:
ValueError("'image' must have either 3 or 4 dimensions, "
"received `{}`.".format(images_shape))
if len(images_shape) == 4:
return tf.map_fn(tf.image.transpose_image, images)
return tf.image.transpose_image(images)
评论列表
文章目录