From 599a8ec386cddcfacf64bd6bb33391ce8bff1aad Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 27 Aug 2024 14:59:28 +0100 Subject: [PATCH] Add comment --- test/test_image.py | 7 ++++++- torchvision/csrc/io/image/cpu/decode_webp.cpp | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/test_image.py b/test/test_image.py index 0e5390da497..8bc18ccf26b 100644 --- a/test/test_image.py +++ b/test/test_image.py @@ -891,7 +891,12 @@ def test_decode_webp(decode_fun, scripted): assert img[None].is_contiguous(memory_format=torch.channels_last) -# TODO: explain this test and why it's skipped +# This test is skipped because it requires webp images that we're not including +# within the repo. The test images were downloaded from the different pages of +# https://developers.google.com/speed/webp/gallery +# Note that converting an RGBA image to RGB leads to bad results because the +# transparent pixels aren't necessarily set to "black" or "white", they can be +# random stuff. This is consistent with PIL results. @pytest.mark.skip(reason="Need to download test images first") @pytest.mark.parametrize("decode_fun", (decode_webp, decode_image)) @pytest.mark.parametrize("scripted", (False, True)) diff --git a/torchvision/csrc/io/image/cpu/decode_webp.cpp b/torchvision/csrc/io/image/cpu/decode_webp.cpp index 174498db047..c5fcc51cec2 100644 --- a/torchvision/csrc/io/image/cpu/decode_webp.cpp +++ b/torchvision/csrc/io/image/cpu/decode_webp.cpp @@ -64,10 +64,6 @@ torch::Tensor decode_webp( auto out = torch::from_blob( decoded_data, {height, width, num_channels}, torch::kUInt8); - if (features.has_alpha && mode == IMAGE_READ_MODE_RGB) { - namespace idx = torch::indexing; - out = out.index({idx::Slice(), idx::Slice(), idx::Slice(idx::None, 3)}); - } return out.permute({2, 0, 1}); } #endif // WEBP_FOUND