pytorch / vision

Datasets, Transforms and Models specific to Computer Vision
https://pytorch.org/vision
BSD 3-Clause "New" or "Revised" License
16.34k stars 6.97k forks source link

[Feature Request] More Image Transforms (Brightness, Contrast, Hue) #271

Closed Kaixhin closed 7 years ago

Kaixhin commented 7 years ago

It would be good to have some more image transforms (manual and random for augmentation). TensorFlow has the following:

alykhantejani commented 7 years ago

a PR with some/most of these is already under review - we should look at getting that merged after #240 is merged.

Kaixhin commented 7 years ago

Didn't spot because I was searching for hue, so thanks for bringing up! Yes makes sense to revisit after both of these are merged in.

chsasank commented 7 years ago

@alykhantejani Shall I work on #27 and continue the PR?

alykhantejani commented 7 years ago

@chsasank the ones in #27 probably need to be re-worked a bit. I'll comment on that PR and see if the authors are willing to make the change.

Do you want to start with Hue and Gamma (not present in #27) and then we can do the others (depending on the state of #27 then)?

chsasank commented 7 years ago

Sure. Any reference on the same? I've seen contrast, saturation transforms but not gamma and hue. Thanks.

On Wed 27 Sep, 2017, 02:55 Alykhan Tejani notifications@github.com wrote:

@chsasank https://github.com/chsasank the ones in #27 https://github.com/pytorch/vision/pull/27 probably need to be re-worked a bit. I'll comment on that PR and see if the authors are willing to make the change.

Do you want to start with Hue and Gamma (not present in #27 https://github.com/pytorch/vision/pull/27) and then we can do the others (depending on the state of #27 https://github.com/pytorch/vision/pull/27 then)?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pytorch/vision/issues/271#issuecomment-332340939, or mute the thread https://github.com/notifications/unsubscribe-auth/AI3_EyOhGizy2B6MSF-PNUPZdkBFZ2cDks5smWvYgaJpZM4PinGK .

Kaixhin commented 7 years ago

Automatic Portrait Segmentation for Image Stylization uses rotation, scale and gamma. Do Deep Convolutional Nets Really Need to be Deep and Convolutional? uses hue, saturation and value. I'm sure there are other papers out there, but I managed to find these two fairly quickly.

alykhantejani commented 7 years ago

@chsasank you can also use Tensorflow's implementation as a guide: https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/python/ops/image_ops_impl.py

chsasank commented 7 years ago

Thanks @Kaixhin, @alykhantejani ! TF implementation is really useful. I'll use function names and their parameters from there.

fmassa commented 7 years ago

@Kaixhin note that for Automatic Portrait Segmentation for Image Stylization, performing simple rotations actually harms performance of the final model (even if you take care of rotating and cropping the image such that no boundary artifacts are introduced due to rotation). Random scale and crop helps a lot though, but having a large number of transforms that in the end do not contribute to the end performance (and even hurts performance) seems that might not be worth to it to me, as it can confuse users (who might thought that more transforms = better).

A few links showing that some transforms might not be helpful:

But we can extend the transforms if you think it's worth it.

Kaixhin commented 7 years ago

@fmassa it's true that naively throwing a lot of augmentations at data may hurt performance, but there are some cases where this extended set can help in particular. I'm currently looking at something where lighting conditions vary a lot 😰 As an example of where these augmentations have been used in practice, here's the transformation code for Single Shot Multibox Detector in ChainerCV.

chsasank commented 7 years ago

I raised PR with hue and saturation transforms at #275. Will add more if interested :)

alykhantejani commented 7 years ago

Closing as these we're addressed in #275