vision icon indicating copy to clipboard operation
vision copied to clipboard

Add a GrayscaleToRgb transform that can expand channels to 3

Open ahmadsharif1 opened this issue 1 year ago • 1 comments
trafficstars

This is for issue #8186.

GrayscaleToRgb transform can take a grayscale image and expand it to 3 channels, with the same values for R, G and B.

ahmadsharif1 avatar Feb 01 '24 23:02 ahmadsharif1

:link: Helpful Links

:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8247

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

:white_check_mark: You can merge normally! (1 Unrelated Failure)

As of commit b2daebd998c9d5ca2a47d054c3ba9133afa883c5 with merge base fa82fd3b106034c2dd5893cf1b7929f391fd1450 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

pytorch-bot[bot] avatar Feb 01 '24 23:02 pytorch-bot[bot]

Thanks a lot @ahmadsharif1 , just one minor comment below but this looks good. Maybe you can undraft the PR? Now it's time to bikeshed about the name. I'm tempted to just call that ToRGB() instead of GrayScaleToRGB() so that it can be called at the beginning of every pipeline without suggesting that the input has to be grayscale...

I can change it to ToRGB, but while we are bikeshedding, I do like function names that start with a verb or action. So how about ConvertToRGB or MaybeExpandChannelsToRGB or something equivalent? WDYT?

I am happy to just go with ToRGB as well. Just let me know.

ahmadsharif1 avatar Mar 04 '24 20:03 ahmadsharif1

As discussed offline, we should just try to be consistent with the existing transforms here (even though the existing transforms themselves are not completely consistent...).

  • We already have the Grayscale transform, so I guess that means we should just have RGB()
  • We have the rgb_to_grayscale() functional, so lets' have grayscale_to_rgb() as well. (We do have to_grayscale(), but it's an oddity that only supports PIL images for whatever reason... so we shouldn't build on it)

Also before merging we'll have to add the transform and the functional to the docs here and here. To check for docs rendering you can either check out instructions in the contributing guide, or (probably easier for now) just wait for the CI job to be done and then check from https://github.com/pytorch/vision/pull/8247#issuecomment-1922504673

NicolasHug avatar Mar 15 '24 13:03 NicolasHug

Hey @ahmadsharif1!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

github-actions[bot] avatar Mar 15 '24 16:03 github-actions[bot]