[Call for Contribution] Image augmenter operators
Goal
Fuse operations like (x - mean)/std into a single operator in backend to speed up IO.
References
- https://github.com/pytorch/vision/blob/master/torchvision/transforms/transforms.py
- https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/image/image.py
- https://github.com/huangzehao/incubator-mxnet-bk/blob/master/src/io/image_aug_default.cc#L240 https://www.tensorflow.org/api_guides/python/image#Image_Adjustments
Operators
mx.nd/sym/image.resized_crop(data, box, size, interp) -> out
- data: H x W x C uint8 tensor
- box: tuple of 4 integers (y, x, h, w)
- size: size integer or (height, width) tuple
- interp: default bilinear
- out: cropped image tensor
mx.nd/sym.image.random_flip(data, axis) -> out
- data: H x W x C uint8 tensor
- axis: 0 or 1, axis along which to flip
- out: C x H x W tensor Note: needs to support inplace operation.
mx.nd/sym.image.to_tensor(data) -> out
- data: H x W x C uint8 tensor
- out: C x H x W float32 tensor
mx.nd/sym.image.normalize(data, mean, std) -> out
- data: C x H x W tensor
- mean: tuple of 1 or 3 floats
- std: tuple of 1 or 3 floats
mx.nd/sym.image.random_brightness(data, max_brightness) -> out
- data: C x H x W tensor
- max_brightness: float
mx.nd/sym.image.random_contrast(data, max_contrast) -> out
- data: C x H x W tensor
- max_contrast: float
mx.nd/sym.image.random_saturation(data, max_saturation) -> out
- data: C x H x W tensor
- max_saturation: float
mx.nd/sym.image.random_hue(data, max_hue) -> out
- data: C x H x W tensor
- max_hue: float
mx.nd/sym.image.random_color_jitter(data, max_brightness, max_contrast, max_saturation, max_hue) -> out
Apply 4 augs in random order
mx.nd/sym.image.random_lighting(data, alphastd, eig) -> out
- data: C x H x W tensor
- alphastd: float
- eig: tuple of 9 floats (might be better to use ndarray? not sure...)
Additional
Also support deterministic versions, e.g. flip, adjust_brightness, etc.
@javelinjs @yajiedesign
I've checked again the APIs in torchvision. The input to all the random augmentation ops (like random_color_jitter) should be a uint8 tensor with (H, W, C) shape.
I like the idea how it is done in pytorch - composing a sequence of transforms.
also: random_crop is a useful idea not mentioned here. same: a random rotation by 90degrees ... if you are in problems with imaging of small sample size rotation symmetric data.
one point to check is: that iterators should be able to work with variable size input images if a resize or crop operator is used ... bcs the output will then have fixed size again, so it would fit into an ndarray.