utils/tf_image_processing.py
def scale(images, out_size=None, scale_factor=1.0, method='NEAREST',
          name=None):
  """ Scale images to a given size.

  `method` can be one of:
  *   `NEAREST`: Nearest neighbor interpolation
  *   `BILINEAR`: Bilinear interpolation
  
  Args:
    images: 4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor
        of shape [height, width, channels].
    out_size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
        size for the images.
    scale_factor: A 0-D Tensor or Python value of type float32. If out_size is 
        not given use the size of `images` and scale it by the given factor.
        Defaults to `1.0`.
    method: Resize method. Defaults do `NEAREST`
    name: A name for the operation (optional).

  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]`
  """
  with tf.name_scope(name, 'ScaleInput', [images]):
    if out_size is None:
      shape = images.get_shape().as_list()
      if images.get_shape().ndims == 3:
        out_size = [int(s * scale_factor) for s in shape[:2]]
      else:
        out_size = [int(s * scale_factor) for s in shape[1:3]]

    images = tf.image.resize_images(
      images, out_size,
      tf.image.ResizeMethod.NEAREST_NEIGHBOR if method is 'NEAREST' else \
        tf.image.ResizeMethod.BILINEAR)

    return images
 Scale images to a given size.

  `method` can be one of:
  *   `NEAREST`: Nearest neighbor interpolation
  *   `BILINEAR`: Bilinear interpolation
  
  Args:
    images: 4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor
        of shape [height, width, channels].
    out_size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
        size for the images.
    scale_factor: A 0-D Tensor or Python value of type float32. If out_size is 
        not given use the size of `images` and scale it by the given factor.
        Defaults to `1.0`.
    method: Resize method. Defaults do `NEAREST`
    name: A name for the operation (optional).

  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]`
  
Scale images to a given size.
Scale images to a given size .
def scale(images, out_size=None, scale_factor=1.0, method='NEAREST',
          name=None):
  with tf.name_scope(name, 'ScaleInput', [images]):
    if out_size is None:
      shape = images.get_shape().as_list()
      if images.get_shape().ndims == 3:
        out_size = [int(s * scale_factor) for s in shape[:2]]
      else:
        out_size = [int(s * scale_factor) for s in shape[1:3]]
    images = tf.image.resize_images(
      images, out_size,
      tf.image.ResizeMethod.NEAREST_NEIGHBOR if method is 'NEAREST' else \
        tf.image.ResizeMethod.BILINEAR)
    return images
def scale ( images , out_size = None , scale_factor = 1.0 , method = 'NEAREST' , name = None ) : with tf . name_scope ( name , 'ScaleInput' , [ images ] ) : if out_size is None : shape = images . get_shape ( ) . as_list ( ) if images . get_shape ( ) . ndims == 3 : out_size = [ int ( s * scale_factor ) for s in shape [ : 2 ] ] else : out_size = [ int ( s * scale_factor ) for s in shape [ 1 : 3 ] ] images = tf . image . resize_images ( images , out_size , tf . image . ResizeMethod . NEAREST_NEIGHBOR if method is 'NEAREST' else tf . image . ResizeMethod . BILINEAR ) return images
Scale images to a given size.
Scale images to a given size .
""" Scale images to a given size.

  `method` can be one of:
  *   `NEAREST`: Nearest neighbor interpolation
  *   `BILINEAR`: Bilinear interpolation
  
  Args:
    images: 4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor
        of shape [height, width, channels].
    out_size: A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
        size for the images.
    scale_factor: A 0-D Tensor or Python value of type float32. If out_size is 
        not given use the size of `images` and scale it by the given factor.
        Defaults to `1.0`.
    method: Resize method. Defaults do `NEAREST`
    name: A name for the operation (optional).

  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]`
  """
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]`
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 ] `
images
4-D Tensor of shape [batch, height, width, channels] or 3-D Tensor
of shape [height, width, channels].
4 - D Tensor of shape [ batch height width channels ] or 3 - D Tensor of shape [ height width channels ] .
out_size
A 1-D int32 Tensor of 2 elements: new_height, new_width. The new
size for the images.
A 1 - D int32 Tensor of 2 elements : new_height new_width . The new size for the images .
scale_factor
A 0-D Tensor or Python value of type float32. If out_size is
not given use the size of `images` and scale it by the given factor.
A 0 - D Tensor or Python value of type float32 . If out_size is not given use the size of ` images ` and scale it by the given factor .
method
Resize method. Defaults do `NEAREST`
Resize method . Defaults do ` NEAREST `
name
A name for the operation (optional).
A name for the operation ( optional ) .