Repository navigation
Fix grayscale detection for RGB images - #283
Open
amrithavdev wants to merge 1 commit into
Open
amrithavdev wants to merge 1 commit into
amrithavdev wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes [Issue #282](#282), where grayscale images stored in RGB mode were incorrectly classified as RGB images instead of grayscale images.
Previously,
get_image_mode()relied on the PIL image'smodeproperty. When a grayscale image was converted to RGB, its mode became"RGB"even though all three color channels (Red, Green, and Blue) contained identical values. As a result, CleanVision could fail to identify these images as grayscale.This change updates
get_image_mode()to check whether all three RGB channels contain identical pixel values. If they do, the image is classified as grayscale ("L"). Otherwise, it retains the"RGB"classification. Existing behavior for other image modes is preserved.Example
Impact
Areas affected:
src/cleanvision/issue_managers/image_property.pyget_image_mode()to detect grayscale images stored in RGB mode.tests/test_image_property_helpers.pytests/test_run.pyWho is affected:
Users who run CleanVision's grayscale image issue detection on datasets containing grayscale images stored in RGB format.
Screenshots
Not applicable. This change does not modify documentation or tutorial notebooks.
Testing
Added tests covering:
L).RGB).RGB).L,RGBA,LA, andP.The complete local pytest suite could not be executed in the Windows environment because of dependency and import restrictions. The added tests are available for verification through CI.
Test Case Link:
[Unit tests – test_image_property_helpers.py](https://github.com/amrithavdev/cleanvision/blob/fix/grayscale-rgb-detection/tests/test_image_property_helpers.py)
Unaddressed Cases
Links to Relevant Issues or Conversations
Closes #282
References
No additional references.
Reviewer Notes