Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random rotate without cropping side #1118

Closed
zheLim opened this issue Jul 28, 2019 · 7 comments
Closed

Random rotate without cropping side #1118

zheLim opened this issue Jul 28, 2019 · 7 comments
Labels
enhancement New feature or request

Comments

@zheLim
Copy link

zheLim commented Jul 28, 2019

Hi, i would like to create random rotate/warpaffine operator without cropping side like OpenCV Python : rotate image without cropping sides.
Firstly I suppose it can be done using Paste+rotate. However, random parameter pass to rotate operator cannot be known. Thus I cannot do padding before rotate. Any suggestion on this problem?

@zheLim
Copy link
Author

zheLim commented Jul 28, 2019

BTW, It is not easy to do Mirror for image and mask at the same time. In my case CropMirrorNorm output wrong mask(i.e. value in msak is not 0/1). FastResizeCrop cannot be used, since mask require resize with inter_NN.

@JanuszL JanuszL added the enhancement New feature or request label Jul 29, 2019
@mzient
Copy link
Contributor

mzient commented Jul 29, 2019

I'm currently reworking all warping operators (rotate, warp affine, etc). New rotate will enlarge canvas to accommodate whole image, while new WarpAffine will accept externally provided canvas size. It should be available quite soon, but I can't commit to any particular release.
Using paste + warp/rotate is possible, but quite wasteful.

@zheLim
Copy link
Author

zheLim commented Jul 29, 2019

@mzient Looking forward to your later commit!

@lxlee
Copy link

lxlee commented Nov 15, 2019

I have the same needs,is there any new solution now?

@JanuszL JanuszL added this to the Release_0.16.0 milestone Nov 15, 2019
@JanuszL
Copy link
Contributor

JanuszL commented Nov 15, 2019

Hi,
Reworked WarpAffine operator is already available in the master branch and you can try is by installing the nightly build of DALI.
An example of how it works can be found https://docs.nvidia.com/deeplearning/sdk/dali-master-branch-user-guide/docs/examples/warp.html.
@mzient anything to add?

@mzient
Copy link
Contributor

mzient commented Nov 15, 2019

Regarding rotate: the new rotate automatically adjusts canvas size to fit the image. Just download the new version and you're set. You can reuse the angles tensor for images and masks, too.
If you need more than just rotation, you can use WarpAffine, but that leaves you on your own with calculating the matrix elements and output sizes. I guess some solution can be hacked together with the combination of ExternalSource for base transform matrices and incorporating the input sizes with the newly-added arithmetic operators (see https://docs.nvidia.com/deeplearning/sdk/dali-master-branch-user-guide/docs/examples/expressions.html) and Shapes operator. If the images at the input to WarpAffine are of uniform size, you can simply calculate the sizes and matrices in python and just feed them to the pipeline through external source.

@JanuszL
Copy link
Contributor

JanuszL commented Dec 19, 2019

This change is available in DALI 0.16.0.

@JanuszL JanuszL closed this as completed Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants