Skip to content

Conversation

@justincdavis
Copy link

Summary

Implements the rgb_to_grayscale and grayscale_to_rgb kernels for CV-CUDA tensors.

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 26, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9284

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 5 New Failures

As of commit f5459e3 with merge base aa35ca1 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla
Copy link

meta-cla bot commented Nov 26, 2025

Hi @justincdavis!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla
Copy link

meta-cla bot commented Dec 1, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the cla signed label Dec 1, 2025

expected = F.to_image(F.rgb_to_grayscale(F.to_pil_image(image), num_output_channels=num_output_channels))

assert_equal(actual, expected, rtol=0, atol=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not part of this PR, but for consistency I'd suggest:
Use assert_equal(a, b) when exact equality is required
Use assert_close(a, b, rtol=..., atol=...) when tolerance is needed
Using assert_equal(..., atol=1) works but is semantically confusing since 'equal' implies exact match.
@NicolasHug Do you think we need to address this?

) -> "cvcuda.Tensor":
cvcuda = _import_cvcuda()

if not (num_output_channels == 1 or num_output_channels == 3):
Copy link
Contributor

Choose a reason for hiding this comment

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

This line might be written in if num_output_channels not in (1, 3): to be consistent with the function _rgb_to_grayscale_image_pil above.

gray = cvcuda.cvtcolor(image, cvcuda.ColorConversion.RGB2GRAY)

if num_output_channels == 3:
gray = cvcuda.cvtcolor(gray, cvcuda.ColorConversion.GRAY2RGB)
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to reassign gray, instead, we can do return cvcuda.cvtcolor(gray, cvcuda.ColorConversion.GRAY2RGB) as above (line 89).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants