Skip to content

Updated random_grayscale.py compute_output_spec #21312

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

Merged
merged 14 commits into from
May 21, 2025

Conversation

pctablet505
Copy link
Collaborator

@pctablet505 pctablet505 commented May 21, 2025

Fixes #21268: Updates compute_output_spec in random_grayscale.py to prevent a computation graph cycle error when RandomGrayscale is used as part of a custom image augmentation pipeline.

pctablet505 and others added 14 commits May 6, 2025 10:25
Corrected indentation in doc string
Fixed issue with passing a single image without batch dimension.
…scale.py

Co-authored-by: Jyotinder Singh <33001894+JyotinderSingh@users.noreply.github.com>
Test case for unbatched inputs
Testcase for checking both unbatched and batched single image inputs.
There was a bug, and it was causing cycle in graph.
@codecov-commenter
Copy link

codecov-commenter commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.60%. Comparing base (7d7a6bb) to head (653f5b1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #21312   +/-   ##
=======================================
  Coverage   82.60%   82.60%           
=======================================
  Files         565      565           
  Lines       54772    54773    +1     
  Branches     8508     8508           
=======================================
+ Hits        45243    45244    +1     
  Misses       7439     7439           
  Partials     2090     2090           
Flag Coverage Δ
keras 82.41% <100.00%> (+<0.01%) ⬆️
keras-jax 63.56% <100.00%> (+<0.01%) ⬆️
keras-numpy 58.70% <50.00%> (-0.01%) ⬇️
keras-openvino 33.13% <50.00%> (+<0.01%) ⬆️
keras-tensorflow 63.96% <100.00%> (+<0.01%) ⬆️
keras-torch 63.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@JyotinderSingh JyotinderSingh 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!

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels May 21, 2025
Copy link
Collaborator

@abheesht17 abheesht17 left a comment

Choose a reason for hiding this comment

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

Thanks!

@abheesht17
Copy link
Collaborator

Looks like I don't have write access either

@fchollet fchollet merged commit 785c9b0 into keras-team:master May 21, 2025
12 checks passed
@google-ml-butler google-ml-butler bot removed awaiting review ready to pull Ready to be merged into the codebase labels May 21, 2025
@@ -96,7 +97,12 @@ def compute_output_shape(self, input_shape):
return input_shape

def compute_output_spec(self, inputs, **kwargs):
return inputs
return tree.map_structure(
Copy link
Collaborator

Choose a reason for hiding this comment

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

There should not be a tree.map_structure in this case, there is a single input tensor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

keras.layers.RandomGrayscale can't be put in as part of image augmentation layer
8 participants