-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Expose hsv_to_rgb
and rgb_to_hsv
#8179
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
Comments
hsv_to_rgb
and rgb_to_hsv
Thank you for the feature request @rehno-lindeque . There was also #4029 opened in the past. So far, we've preferred not exposing such conversion utils in torchvision (see e.g. #4029 (comment)), mainly because every single transform and model in torchvision assumes images are RGB (or grayscale). We do not have a way to tell distinguish between an RGB and HSV images and that could lead to wrong transformations being applied. (It is technically possible to distinguish via meta-data, but it's not something deemed valuable enough considering the high maintenance cost). For now, the recommended way is simply to copy/paste the _hsv_to_rgb and _rgb_to_hsv utils into your own code-base. You could also rely on them directly, but since they're private, there is no backward-compatibility guarantee. |
Thanks Nicolas, and apologies for missing this discussion.
I threw together a tiny gist package for my purposes shortly after I opened the issue and that solved my immediate problem. Just to mention, I didn't copy-paste because I felt it could be a bit dubious wrt licensing. I suspect it might not be the best recommendation for commercial users with proprietary code since it would be easy for the code to end up somewhere without the license. |
Uh oh!
There was an error while loading. Please reload this page.
🚀 The feature
Expose
torchvision.transforms.functional.hsv_to_rgb
andtorchvision.transforms.functional.rgb_to_hsv
in the public api.Motivation, pitch
There is already a private
_hsv_to_rgb
and_rgb_to_hsv
(and the older_hsv2rgb
,_rgb2hsv
).I'd like to use
hsv_to_rgb
directly in my project in order to visualize complex number fields.Alternatives
There exists matplotlib.colors.hsv_to_rgb, and PIL.Image.Image.convert.
However there are numerous advantages to working directly with the pytorch tensors instead of converting back and forth.
Additional context
This should also help with implementing other custom transforms on top of HSV.
The text was updated successfully, but these errors were encountered: