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

Add center crop #22750

Closed
wants to merge 3 commits into from
Closed

Add center crop #22750

wants to merge 3 commits into from

Conversation

alec-kr
Copy link
Contributor

@alec-kr alec-kr commented Aug 29, 2023

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

@github-actions
Copy link
Contributor

Thanks for contributing to Ivy! 😊👏
Here are some of the important points from our Contributing Guidelines 📝:
1. Feel free to ignore the run_tests (1), run_tests (2), … jobs, and only look at the display_test_results job. 👀 It contains the following two sections:
- Combined Test Results: This shows the results of all the ivy tests that ran on the PR. ✔️
- New Failures Introduced: This lists the tests that are passing on main, but fail on the PR Fork. Please try to make sure that there are no such tests. 💪
2. The lint / Check formatting / check-formatting tests check for the formatting of your code. 📜 If it fails, please check the exact error message in the logs and fix the same. ⚠️🔧
3. Finally, the test-docstrings / run-docstring-tests check for the changes made in docstrings of the functions. This may be skipped, as well. 📚
Happy coding! 🎉👨‍💻

@ivy-leaves ivy-leaves added the Paddle Frontend Developing the Paddle Frontend, checklist triggered by commenting add_frontend_checklist label Aug 29, 2023
i = (h - th) // 2
j = (w - tw) // 2

return img[..., i:i+th, j:j+tw]
Copy link
Contributor

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.

Copy link
Contributor

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.

@ivy-seed ivy-seed assigned Ishticode and unassigned vaithak Sep 18, 2023
Copy link
Contributor

@Ishticode Ishticode left a 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 🙂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Paddle Frontend Developing the Paddle Frontend, checklist triggered by commenting add_frontend_checklist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

center_crop
6 participants