-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add image rotation #553
Add image rotation #553
Conversation
Thanks! I'll leave it to @maxfreu to comment on the algorithmic piece, but the biggest outstanding addition here would be making the test suite device-agnostic so it can be tested on GPU CI too. Have a look at the upsample tests for how this is done if you haven't already. |
ImageTransformations.jl doesn't work on GPUs but we can probably wrap it in But yeah, I see and can fix it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I reviewed the code and made some remarks. Maybe someone else should take a look, too. One last point: Please check the output of @code_warntype
for the different functions you wrote and make sure everything is blue (:
Thanks for the comments. |
There is an issue with FillArrays.jl which I don't know how to solve. It seems to fail catch the backend with FillArrays.
|
The StackOverflow is JuliaGPU/KernelAbstractions.jl#366 manifesting again. https://github.com/JuliaGPU/KernelAbstractions.jl/blob/96b89f994e08b48b0a3142d7db4b1c97be054b41/src/KernelAbstractions.jl#L466 should probably check if |
But would KA know that the desired array is a CuArray and not an Array? FillArrays don't have hardware backends, right? So I guess we would need to fill a real array with the FillArray? |
Thanks, I fixed it and added documentation! |
Some GPU test fail but also in parts I didn't touch. Maybe I should relax the |
Another question regardin KA.jl: should we include a |
I think the only open point is the slight disagreement for nearest neighbor for some specific angles to In fact, ImageTransformations is also not tested for that many angles to some reference implementation. |
Ok, now the tests are working - except for one gradient test. That should be investigated and if it's just about tolerance, that can be relaxed a bit. But now somehow 300+ other tests fail. Is this related to your changes or the latest merge by @ToucheSir ? |
I can check later or tomorrow for the failing gradient test. |
It may also be a regression caused by changes in a different package like Zygote or ChainRules(Core). The error looks like some method ambiguity issues have shown up again... |
I lowered the accuracy for the |
I just checked the test logs more carefully and indeed, the test failure is unrelated to your changes and a victim of the same error that broke the other tests. 1e-6 should be ok, sorry for the noise. |
This reverts commit fcba1c3.
I see, JuliaDiff/ChainRules.jl#762 is causing Zygote to be significantly downgraded and breaking. Normally I would be comfortable ignoring that if none of the functionality this PR adds is affected, but there do seem to be tests that downgrade causes errors in that obscure the actual error. For now, we may have to park this until the ChainRules PR is merged. |
I think ChainRules got merged |
I think this PR is finally ready 🍕 |
The CI still was complaining, wasn't it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failures are known and unrelated. Thanks @roflmaostc for the great work! |
Thanks for your work! Does NNlib.jl actually have more methods with preallocated buffers? This helps if you rotate a lot of images and want to add them into the same buffer each. |
Yes, see functions like |
Ok, looks good. I might tackle this in future then! |
Thanks for your work also from my side! :) |
Hi,
based on DiffImageRotation.jl and as discussed in #552 I tried to add image rotation into NNlib.jl.
Some comments:
I always assumed a 4D array. In principle, the results match the ones from ImageTransformations.jl closely. But, the boundary handling is different and sometimes rounding artifacts occur.
I compared this a little but I think there is space for interpretation how to do it. There is some code left, to change the boundary handling at the cost of ~20% performance.
PR Checklist
Benchmarks
@maxfreu mentioned something about different parallelization schemes for CPU vs GPU.
Benchmarking between my implementation and the parallelized elementwise application shows that the timings are roughly equal. So not sure if we should make the code much more verbose and complicated? But please share your experience with me! Especially, if we can squeeze out more performance out of CUDA, that would be great! But on CPU we already beat existing code:
Some benchmarking:
Comparison to ImageTransformations:
Would be great if someone reviews this and we can merge it! Not urgent for me, since DiffImageRotation.jl is registered and I anyway use this currently.