Vision: Padding with reflection [feature request]

Created on 27 Jan 2018  路  6Comments  路  Source: pytorch/vision

Not sure to add this, as it is not supported by PIL. I've been using opencv, but it has all sorts of problems, from installation issues to initializing cuda every multiprocessing thread and protobuf, and I have to copy this file in every project.

enhancement help wanted

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

All 6 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yxlabs picture yxlabs  路  4Comments

Linardos picture Linardos  路  4Comments

xuanqing94 picture xuanqing94  路  3Comments

300LiterPropofol picture 300LiterPropofol  路  3Comments

iacolippo picture iacolippo  路  4Comments