slim/preprocessing/vgg_preprocessing.py
def _crop(image, offset_height, offset_width, crop_height, crop_width):
  """Crops the given image using the provided offsets and sizes.

  Note that the method doesn't assume we know the input image size but it does
  assume we know the input image rank.

  Args:
    image: an image of shape [height, width, channels].
    offset_height: a scalar tensor indicating the height offset.
    offset_width: a scalar tensor indicating the width offset.
    crop_height: the height of the cropped image.
    crop_width: the width of the cropped image.

  Returns:
    the cropped (and resized) image.

  Raises:
    InvalidArgumentError: if the rank is not 3 or if the image dimensions are
      less than the crop size.
  """
  original_shape = tf.shape(input=image)

  rank_assertion = tf.Assert(
      tf.equal(tf.rank(image), 3),
      ['Rank of image must be equal to 3.'])
  with tf.control_dependencies([rank_assertion]):
    cropped_shape = tf.stack([crop_height, crop_width, original_shape[2]])

  size_assertion = tf.Assert(
      tf.logical_and(
          tf.greater_equal(original_shape[0], crop_height),
          tf.greater_equal(original_shape[1], crop_width)),
      ['Crop size greater than the image size.'])

  offsets = tf.cast(tf.stack([offset_height, offset_width, 0]), dtype=tf.int32)

  # Use tf.slice instead of crop_to_bounding box as it accepts tensors to
  # define the crop size.
  with tf.control_dependencies([size_assertion]):
    image = tf.slice(image, offsets, cropped_shape)
  return tf.reshape(image, cropped_shape)
Crops the given image using the provided offsets and sizes.

  Note that the method doesn't assume we know the input image size but it does
  assume we know the input image rank.

  Args:
    image: an image of shape [height, width, channels].
    offset_height: a scalar tensor indicating the height offset.
    offset_width: a scalar tensor indicating the width offset.
    crop_height: the height of the cropped image.
    crop_width: the width of the cropped image.

  Returns:
    the cropped (and resized) image.

  Raises:
    InvalidArgumentError: if the rank is not 3 or if the image dimensions are
      less than the crop size.
  
Crops the given image using the provided offsets and sizes.
Note that the method doesn't assume we know the input image size but it does
assume we know the input image rank.
Crops the given image using the provided offsets and sizes . Note that the method doesn ' t assume we know the input image size but it does assume we know the input image rank .
def _crop(image, offset_height, offset_width, crop_height, crop_width):
  original_shape = tf.shape(input=image)
  rank_assertion = tf.Assert(
      tf.equal(tf.rank(image), 3),
      ['Rank of image must be equal to 3.'])
  with tf.control_dependencies([rank_assertion]):
    cropped_shape = tf.stack([crop_height, crop_width, original_shape[2]])
  size_assertion = tf.Assert(
      tf.logical_and(
          tf.greater_equal(original_shape[0], crop_height),
          tf.greater_equal(original_shape[1], crop_width)),
      ['Crop size greater than the image size.'])
  offsets = tf.cast(tf.stack([offset_height, offset_width, 0]), dtype=tf.int32)
  with tf.control_dependencies([size_assertion]):
    image = tf.slice(image, offsets, cropped_shape)
  return tf.reshape(image, cropped_shape)
def _crop ( image , offset_height , offset_width , crop_height , crop_width ) : original_shape = tf . shape ( input = image ) rank_assertion = tf . Assert ( tf . equal ( tf . rank ( image ) , 3 ) , [ 'Rank of image must be equal to 3.' ] ) with tf . control_dependencies ( [ rank_assertion ] ) : cropped_shape = tf . stack ( [ crop_height , crop_width , original_shape [ 2 ] ] ) size_assertion = tf . Assert ( tf . logical_and ( tf . greater_equal ( original_shape [ 0 ] , crop_height ) , tf . greater_equal ( original_shape [ 1 ] , crop_width ) ) , [ 'Crop size greater than the image size.' ] ) offsets = tf . cast ( tf . stack ( [ offset_height , offset_width , 0 ] ) , dtype = tf . int32 ) with tf . control_dependencies ( [ size_assertion ] ) : image = tf . slice ( image , offsets , cropped_shape ) return tf . reshape ( image , cropped_shape )
Crops the given image using the provided offsets and sizes.
Crops the given image using the provided offsets and sizes .
"""Crops the given image using the provided offsets and sizes.

  Note that the method doesn't assume we know the input image size but it does
  assume we know the input image rank.

  Args:
    image: an image of shape [height, width, channels].
    offset_height: a scalar tensor indicating the height offset.
    offset_width: a scalar tensor indicating the width offset.
    crop_height: the height of the cropped image.
    crop_width: the width of the cropped image.

  Returns:
    the cropped (and resized) image.

  Raises:
    InvalidArgumentError: if the rank is not 3 or if the image dimensions are
      less than the crop size.
  """ # Use tf.slice instead of crop_to_bounding box as it accepts tensors to # define the crop size.
the cropped (and resized) image.
the cropped ( and resized ) image .
if the rank is not 3 or if the image dimensions are
less than the crop size.
if the rank is not 3 or if the image dimensions are less than the crop size .
InvalidArgumentError
image
an image of shape [height, width, channels].
an image of shape [ height width channels ] .
offset_height
a scalar tensor indicating the height offset.
a scalar tensor indicating the height offset .
offset_width
a scalar tensor indicating the width offset.
a scalar tensor indicating the width offset .
crop_height
the height of the cropped image.
the height of the cropped image .
crop_width
the width of the cropped image.
the width of the cropped image .