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

🐞 Replace the mandatory PatchCore center crop with an optional one, add the same to CFA #2623

Merged

Conversation

abc-125
Copy link
Contributor

@abc-125 abc-125 commented Mar 22, 2025

📝 Description

This PR replaces the mandatory PatchCore center crop with an optional one. It solves that center crop transform is often not needed in practical applications, but at the same time, it allows easily add it to reproduce paper settings:

# Configure pre-processor to reproduce paper settings
pre_processor = Patchcore.configure_pre_processor(
  image_size=(256, 256),
  center_crop_size=(224, 224)
)

The same option is provided for CFA, which, like PatchCore, uses the center crop in its official implementation.

Not having a center crop transform does not affect how these models work. It just improves results on data where the object is in the center of the image, and some background can be removed safely without missing defects, which is not necessarily the case in practical applications.

✨ Changes

If no center_crop_size is provided, the center crop transform won't be applied to the PatchCore and CFA models. If it is provided and smaller than the image size, it will be applied as before.

Select what type of change your PR is:

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🔨 Refactor (non-breaking change which refactors the code base)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔒 Security update

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📋 I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

@abc-125 abc-125 requested a review from samet-akcay as a code owner March 22, 2025 13:35
@abc-125 abc-125 changed the title Replace the mandatory PatchCore center crop with an optional one, add the same to CFA 🐞 Replace the mandatory PatchCore center crop with an optional one, add the same to CFA Mar 22, 2025
Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@samet-akcay samet-akcay merged commit 03dc126 into openvinotoolkit:main Mar 24, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Patchcore changes image resolution and heatmaps become offset
2 participants