grayscale only checks image.mode, misses grey images stored as RGB

Open Beginner friendly
#282 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
computer-vision, python

Research direction

Find get_image_mode and the grayscale checks used by find_issues(issue_types={"grayscale": {}}). Reproduce the report with RGB PNGs whose three channels are identical, then read the existing channel comparison and related tests. Done when those images are flagged as grayscale while non-gray RGB images are not.

Written by the indexing model from the issue text.

Description

get_image_mode returns image.mode whenever it is set, which PIL always does on load, so the
channel comparison in the else branch never runs for files read from disk. A grey image saved
as RGB (e.g. after a colour-space conversion to sRGB, which most preprocessing pipelines do)
is never flagged.

Reproduction: save 20 single-channel random images via Image.fromarray(g).convert("RGB") as
PNG, run find_issues(issue_types={"grayscale": {}}) -> 0 flagged.

Expected: images with three identical channels flagged as grayscale (the else branch already
does exactly that; it is just unreachable when image.mode is set).

Dominant language
Python
Stars
1.2k
Forks
87
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cleanlab/cleanvision

All issues in cleanlab/cleanvision

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.