src/core/datasets/tasks.py
def adjust_resolution(image, sizes, mask=None):
  """Adjust input image sizes to be within the expected `sizes`.

  Example:
    shape = (512, 1024, 3)
    sizes = (512, 512)
    =>
    out shape = (256, 512, 3)

  """
  es = tf.constant(sizes, tf.float32)
  xs = tf.cast(tf.shape(image)[:2], tf.float32)

  ratio = tf.reduce_min(es / xs)
  xsn = tf.math.ceil(ratio * xs)

  target_shape = tf.cast(xsn, tf.int32)
  image = tf.image.resize(image, target_shape, preserve_aspect_ratio=True, method='nearest')

  if not mask:
    return image, ratio, xsn/es
    
  mask = tf.image.resize(mask, target_shape, preserve_aspect_ratio=True, method='nearest')

  return image, mask, ratio, xsn/es
Adjust input image sizes to be within the expected `sizes`.

  Example:
    shape = (512, 1024, 3)
    sizes = (512, 512)
    =>
    out shape = (256, 512, 3)

  
Adjust input image sizes to be within the expected `sizes`.
Adjust input image sizes to be within the expected ` sizes ` .
def adjust_resolution(image, sizes, mask=None):
  es = tf.constant(sizes, tf.float32)
  xs = tf.cast(tf.shape(image)[:2], tf.float32)
  ratio = tf.reduce_min(es / xs)
  xsn = tf.math.ceil(ratio * xs)
  target_shape = tf.cast(xsn, tf.int32)
  image = tf.image.resize(image, target_shape, preserve_aspect_ratio=True, method='nearest')
  if not mask:
    return image, ratio, xsn/es
  mask = tf.image.resize(mask, target_shape, preserve_aspect_ratio=True, method='nearest')
  return image, mask, ratio, xsn/es
def adjust_resolution ( image , sizes , mask = None ) : es = tf . constant ( sizes , tf . float32 ) xs = tf . cast ( tf . shape ( image ) [ : 2 ] , tf . float32 ) ratio = tf . reduce_min ( es / xs ) xsn = tf . math . ceil ( ratio * xs ) target_shape = tf . cast ( xsn , tf . int32 ) image = tf . image . resize ( image , target_shape , preserve_aspect_ratio = True , method = 'nearest' ) if not mask : return image , ratio , xsn / es mask = tf . image . resize ( mask , target_shape , preserve_aspect_ratio = True , method = 'nearest' ) return image , mask , ratio , xsn / es
Adjust input image sizes to be within the expected `sizes`.
Adjust input image sizes to be within the expected ` sizes ` .
"""Adjust input image sizes to be within the expected `sizes`.

  Example:
    shape = (512, 1024, 3)
    sizes = (512, 512)
    =>
    out shape = (256, 512, 3)

  """
image
sizes
mask
examples
None