By using tf.random_uniform we can randomly select one of these crops. This function returns a new image for each crop box, resulting in 20 potential cropped images for each input image. These boxes are created once and then passed on to the crop_and_resize function. In the augmentation function below we first create 20 crop boxes using numpy. The function requires a list of ‘crop boxes’ that contain normalized coordinates (between 0 and 1) for cropping. The Tensorflow function crop_and_resize function comes close as it can crop an image and then resize it to an arbitrary size. This augmentation is a bit harder to implement as there is no single function that performs this operation completely. Zooming is a powerful augmentation that can make a network robust to (small) changes in object size. These values can be tuned to fit the target dataset. random_contrast ( x, 0.7, 1.3 ) return xĬolor augmentations applied to the dataset. random_saturation ( x, 0.6, 1.6 ) x = tf. Random functions from Tensorflow are evaluated for every input, functions from numpy or basic python only once which would result in a static augmentation.ĭef color ( x : tf. To get a new random rotation for each image we need to use a random function from Tensorflow itself. For this we can use the rot90 function of Tensorflow. One of the most simplest augmentations is rotating the image 90 degrees. Of course, there are many more augmentations that could be useful, but most of them follow the same approach. Nevertheless, I show them here as an example as they can be useful for tasks that are more orientation invariant. learning to detect flipped trucks is maybe not that beneficial for the task at hand. Not all of these augmentations are necessarily applicable to CIFAR10 e.g. Color augmentations (hue, saturation, brightness, contrast).With this basic recipe for an augmenter function we can implement the augmenters itself.
0 Comments
Leave a Reply. |