본문 바로가기

Deep Learning

[data augmentation] random image flip left/right

반응형

def _random_flip_left_right(image_batch, label_batch, batch_size):


for i in range(batch_size):

if (np.random.rand(1) < 0.5):
sign = -1.0
tmp_image = np.fliplr(image_batch[i, :, :, :])
else:
sign = 1.0
tmp_image = image_batch[i, :, :, :]


tmp_steer = label_batch[i, 0]

image_batch[i, :, :, :] = tmp_image
label_batch[i, 0] = sign * tmp_steer

return image_batch, label_batch