-
-
Notifications
You must be signed in to change notification settings - Fork 9
Speedup normalize #60
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
Conversation
Reviewer's GuideThis PR optimizes per-image normalization by narrowing the LUT path to 3-channel uint8 images, removes the standalone batch normalization function and its tests to simplify the API, and increments the package version. Class diagram for normalization function changesclassDiagram
class functions {
+normalize_per_image(img: np.ndarray, normalization: NormalizationType) np.ndarray
-normalize_per_image_batch(images: np.ndarray, normalization: NormalizationType, spatial_axes: tuple[int, ...]) np.ndarray
+to_float_numpy(img: np.ndarray, max_value: float | None = None) np.ndarray
}
functions : -normalize_per_image_batch removed
functions : +normalize_per_image updated
functions : +to_float_numpy unchanged
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Pull Request Overview
This PR aims to speed up image normalization by refining the normalization path for single images and deprecating the batch normalization API. Key changes include:
- Removal of the batch normalization test and its implementation.
- Update of the normalization condition in functions.py to restrict LUT-based normalization to 3D uint8 images.
- Version bump in pyproject.toml from 0.0.29 to 0.0.30.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_normalize_per_image.py | Removed tests for the deprecated batch normalization method. |
| pyproject.toml | Updated version to reflect the new release. |
| albucore/functions.py | Updated LUT normalization condition and removed batch normalization. |
Comments suppressed due to low confidence (2)
tests/test_normalize_per_image.py:138
- The batch normalization test and its corresponding functionality have been removed. Please update the public API documentation to reflect this change if the removal was intentional.
def test_normalize_per_image_constant(shape, normalization, dtype):
albucore/functions.py:712
- [nitpick] The updated condition limits LUT normalization to 3D images; please update the function's docstring to clarify that non-3D images will be handled by the OpenCV implementation.
if img.dtype == np.uint8 and normalization != "image_per_channel" and img.ndim == 3:
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #60 +/- ##
=======================================
Coverage ? 93.97%
=======================================
Files ? 17
Lines ? 1793
Branches ? 0
=======================================
Hits ? 1685
Misses ? 108
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Bug: Grayscale Image Normalization Performance Issue
The img.ndim == 3 condition added in the normalize_per_image function (line 712) unnecessarily restricts the fast LUT optimization path. This forces 2D uint8 grayscale images (shape (H, W)) to use the slower OpenCV normalization method instead of the faster normalize_per_image_lut function, causing a performance regression. The normalize_per_image_lut function is capable of handling 2D inputs.
albucore/functions.py#L711-L712
albucore/albucore/functions.py
Lines 711 to 712 in 0228681
| """ | |
| if img.dtype == np.uint8 and normalization != "image_per_channel" and img.ndim == 3: |
BugBot free trial expires on July 22, 2025
You have used $0.00 of your $20.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
Summary by Sourcery
Simplify the image normalization module by removing batch-based normalization, restricting LUT-based optimization to standard 3D images, and updating the package version.
Enhancements:
Tests:
Chores: