Yeah, the fact that PIL doesn't support this makes it a bit annoying.
But a workaround (which works in the GPU as well) is to use F.pad as the first operation in your network.
What do you think about that?
@fmassa the way augmentation works is you first pad with reflection, then do random crops from the padded image.
forgot to mention, there is np.pad which supports various padding including reflection
Yeah, I realized after I commented that one might want to add random crops after padding, but I'm not sure what's the real use-case because one usually pads the input to remove the effect of size reduction in convolutions, but well.
But yes, be could convert to numpy, add np.pad. There is btw a pending PR that does exactly that, maybe someone could finish it? https://github.com/pytorch/vision/pull/213
We recently needed this feature in a project and ended up using opencv. I see that there is a PR #213 but it is still waiting response from the author since Jul 2017. I would like to finish it. Is it better to send a new PR with the requested changes of @fmassa and @alykhantejani or how should I proceed?
@utkuozbulak sending a new PR is perfect. Thanks a lot!
Fixed by #460
Most helpful comment
@fmassa the way augmentation works is you first pad with reflection, then do random crops from the padded image.
forgot to mention, there is np.pad which supports various padding including reflection