-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Warn when webp is asked to decode into grayscale #9101
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,11 @@ torch::Tensor decode_webp( | |
| res == VP8_STATUS_OK, "WebPGetFeatures failed with error code ", res); | ||
| TORCH_CHECK( | ||
| !features.has_animation, "Animated webp files are not supported."); | ||
| TORCH_WARN_ONCE( | ||
| mode == IMAGE_READ_MODE_GRAY || | ||
| mode == IMAGE_READ_MODE_GRAY_ALPHA, | ||
|
||
| "Webp does not support grayscale conversions. " | ||
| "The returned tensor will be in the colorspace of the original image."); | ||
|
|
||
| auto return_rgb = | ||
| should_this_return_rgb_or_rgba_let_me_know_in_the_comments_down_below_guys_see_you_in_the_next_video( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a shame we don't get a nice python warning, but I guess that'll do for now. We can still catch it by adding the
capfdfixture , and then something like:Now the first test parametrization with
decode_webpwill pass, but the one withdecode_imagewill fail as expected, because we only warn once. Maybe we should only testdecode_imagethen, since it's the highest-level function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if we're capturing the output, then both functions should pass the test, as
decode_webp()calls the C++ function of the same name - and that's where the check is. I'll see if I can improve it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: I misread your comment, as you were talking about the warn-once aspect. I addressed that with the API that lets us temporarily turn on warnings all the time. Without it, both tests failed, which means that some test somewhere was already triggering the warning.