-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 center crop #22750
Add center crop #22750
Conversation
Thanks for contributing to Ivy! 😊👏 |
i = (h - th) // 2 | ||
j = (w - tw) // 2 | ||
|
||
return img[..., i:i+th, j:j+tw] |
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.
HI @alec-kr, you should also handle the case when output_size is greater than shape.
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.
Can you verify that this is consistent with paddle's output? Because torch seems to handle this in a different way, by padding the image till the size matches the output.
Also, one test seems to be failing for such a case because of difference with ground truth output.
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.
Hi @alec-kr
The tests are failing with error E AssertionError: returned shape = (3, 3, 3), ground-truth returned shape = (3, 1, 1)
with numpy backend for example.
Could you look into a fix and request a review when done. Let me know if you are unsure about any aspect. Thanks 🙂️
PR Description
This PR adds the
center_crop
function from PaddlePaddle to the Ivy repository frontend and includes the corresponding test.Related Issue
Close #22749