Last active
March 4, 2018 21:33
-
-
Save tomahim/d00013aa061e8a130d01c9b4178e0cab to your computer and use it in GitHub Desktop.
Apply random transformations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dictionary of the transformations functions we defined earlier | |
available_transformations = { | |
'rotate': random_rotation, | |
'noise': random_noise, | |
'horizontal_flip': horizontal_flip | |
} | |
# random num of transformations to apply | |
num_transformations_to_apply = random.randint(1, len(available_transformations)) | |
num_transformations = 0 | |
transformed_image = None | |
while num_transformations <= num_transformations_to_apply: | |
# choose a random transformation to apply for a single image | |
key = random.choice(list(available_transformations)) | |
transformed_image = available_transformations[key](image_to_transform) | |
num_transformations += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment