def random_crop(img, p):
    if (np.random.sample() <= p):
        dim = np.array(img).shape
        height = dim[0]
        width = dim[1]
        cropped_height = (height / 5)
        cropped_width = (width / 5)
        init_height = (np.random.random_sample() * cropped_height)
        init_width = (np.random.random_sample() * cropped_width)
        end_height = ((height - cropped_height) + init_height)
        end_width = ((width - cropped_width) + init_width)
        return img.crop((init_width, init_height, end_width, end_height)).resize((height, width))
    else:
        return img
def random_crop(img, p):
    if (np.random.sample() <= p):
        dim = np.array(img).shape
        height = dim[0]
        width = dim[1]
        cropped_height = (height / 5)
        cropped_width = (width / 5)
        init_height = (np.random.random_sample() * cropped_height)
        init_width = (np.random.random_sample() * cropped_width)
        end_height = ((height - cropped_height) + init_height)
        end_width = ((width - cropped_width) + init_width)
        return img.crop((init_width, init_height, end_width, end_height)).resize((height, width))
    else:
        return img