Skip to content

Fix grayscale conversion for HWC NumPy RGB inputs - #15415

Open
dcaayushd wants to merge 2 commits into
huggingface:mainfrom
dcaayushd:bugfix/numpy-grayscale
Open

dcaayushd wants to merge 2 commits into
huggingface:mainfrom
dcaayushd:bugfix/numpy-grayscale

Conversation

@dcaayushd

Copy link
Copy Markdown
Contributor

What does this PR do?

When do_convert_grayscale=True, HWC NumPy RGB/RGBA inputs were treated as batches of grayscale images instead of being converted. This converts their color channels to grayscale before shape handling and adds a regression test for the output shape and values.

No dependencies added.

Validation

  • /tmp/diffusers-bughunt-venv/bin/python -m pytest tests/others/test_image_processor.py -q — 14 passed, 2 warnings.
  • PATH=/tmp/diffusers-bughunt-venv/bin:$PATH make style — passed.
  • PATH=/tmp/diffusers-bughunt-venv/bin:$PATH make quality — passed.

Self-review notes: The change is limited to 3D HWC NumPy inputs and its regression test. 4D NumPy batches, lists, and 3D color tensors were not changed. The repository self-review skill has not been run yet.

Fixes #15414

Before submitting

  • Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
    • Did you read the Coding with AI agents guide?
    • Did you run the self-review skill on the diff?
    • Did you share the final self-review notes in the PR description or a comment?
  • Did you read the contributor guideline?
  • Did you read our philosophy doc? (important for complex PRs)
  • Was this discussed/approved via a GitHub issue or GitHub Discussions? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? No documentation update is needed; this restores the configured grayscale conversion behavior.
  • Did you write any new necessary tests?
  • Are you the author (or part of the team we work with) of the model/pipeline this PR relates to?

Who can review?

@sayakpaul @yiyixuxu

@github-actions github-actions Bot added tests fixes-issue size/S PR with diff < 50 LOC labels Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes-issue size/S PR with diff < 50 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VaeImageProcessor misinterprets HWC NumPy RGB inputs with do_convert_grayscale

1 participant