deepaugment/image_generator.py
def zero_pad_and_crop(img, amount=4):
    """Zero pad by `amount` zero pixels on each side then take a random crop.
  Args:
    img: numpy image that will be zero padded and cropped.
    amount: amount of zeros to pad `img` with horizontally and verically.
  Returns:
    The cropped zero padded img. The returned numpy array will be of the same
    shape as `img`.
  """
    padded_img = np.zeros(
        (img.shape[0] + amount * 2, img.shape[1] + amount * 2, img.shape[2])
    )
    padded_img[amount : img.shape[0] + amount, amount : img.shape[1] + amount, :] = img
    top = np.random.randint(low=0, high=2 * amount)
    left = np.random.randint(low=0, high=2 * amount)
    new_img = padded_img[top : top + img.shape[0], left : left + img.shape[1], :]
    return new_img
Zero pad by `amount` zero pixels on each side then take a random crop.
  Args:
    img: numpy image that will be zero padded and cropped.
    amount: amount of zeros to pad `img` with horizontally and verically.
  Returns:
    The cropped zero padded img. The returned numpy array will be of the same
    shape as `img`.
  
Zero pad by `amount` zero pixels on each side then take a random crop.
Zero pad by ` amount ` zero pixels on each side then take a random crop .
def zero_pad_and_crop(img, amount=4):
    padded_img = np.zeros(
        (img.shape[0] + amount * 2, img.shape[1] + amount * 2, img.shape[2])
    )
    padded_img[amount : img.shape[0] + amount, amount : img.shape[1] + amount, :] = img
    top = np.random.randint(low=0, high=2 * amount)
    left = np.random.randint(low=0, high=2 * amount)
    new_img = padded_img[top : top + img.shape[0], left : left + img.shape[1], :]
    return new_img
def zero_pad_and_crop ( img , amount = 4 ) : padded_img = np . zeros ( ( img . shape [ 0 ] + amount * 2 , img . shape [ 1 ] + amount * 2 , img . shape [ 2 ] ) ) padded_img [ amount : img . shape [ 0 ] + amount , amount : img . shape [ 1 ] + amount , : ] = img top = np . random . randint ( low = 0 , high = 2 * amount ) left = np . random . randint ( low = 0 , high = 2 * amount ) new_img = padded_img [ top : top + img . shape [ 0 ] , left : left + img . shape [ 1 ] , : ] return new_img
Zero pad by `amount` zero pixels on each side then take a random crop.
Zero pad by ` amount ` zero pixels on each side then take a random crop .
"""Zero pad by `amount` zero pixels on each side then take a random crop.
  Args:
    img: numpy image that will be zero padded and cropped.
    amount: amount of zeros to pad `img` with horizontally and verically.
  Returns:
    The cropped zero padded img. The returned numpy array will be of the same
    shape as `img`.
  """
The cropped zero padded img. The returned numpy array will be of the same
shape as `img`.
The cropped zero padded img . The returned numpy array will be of the same shape as ` img ` .
img
numpy image that will be zero padded and cropped.
numpy image that will be zero padded and cropped .
amount
amount of zeros to pad `img` with horizontally and verically.
amount of zeros to pad ` img ` with horizontally and verically .