vision
vision copied to clipboard
Add a GrayscaleToRgb transform that can expand channels to 3
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.
:link: Helpful Links
:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/8247
- :page_facing_up: Preview Python docs built from this PR
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 ():
FLAKY - The following job failed but was likely due to flakiness present on trunk:
- Tests / unittests-linux (3.9, linux.12xlarge, cpu) / linux-job (gh)
The process '/usr/bin/git' failed with exit code 128
This comment was automatically generated by Dr. CI and updates every 15 minutes.
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 ofGrayScaleToRGB()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.
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
Grayscaletransform, so I guess that means we should just haveRGB() - We have the
rgb_to_grayscale()functional, so lets' havegrayscale_to_rgb()as well. (We do haveto_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
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