def imageSummary(opt, image, tag, H, W): blockSize = opt.visBlockSize imageOne = tf.batch_to_space(image[:blockSize**2], crops=[[0, 0], [0, 0]], block_size=blockSize) imagePermute = tf.reshape(imageOne, [H, blockSize, W, blockSize, -1]) imageTransp = tf.transpose(imagePermute, [1, 0, 3, 2, 4]) imageBlocks = tf.reshape(imageTransp, [1, H * blockSize, W * blockSize, -1]) summary = tf.summary.image(tag, imageBlocks) return summary
def upscale(images, scale): """Box upscaling (also called nearest neighbors) of images. Args: images: A 4D `Tensor` in NHWC format. scale: A positive integer scale. Returns: A 4D `Tensor` of `images` up scaled by a factor `scale`. Raises: ValueError: If `scale` is not a positive integer. """ scale = _get_validated_scale(scale) if scale == 1: return images return tf.batch_to_space(tf.tile(images, [scale**2, 1, 1, 1]), crops=[[0, 0], [0, 0]], block_size=scale)