Skip to content
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

Reapply "Fix memory leak in decode_webp (#8712)" (#8723) #8724

Merged
merged 22 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6282f2c
Reapply "Fix memory leak in decode_webp (#8712)" (#8723)
NicolasHug Nov 12, 2024
5439bc0
Merge branch 'main' into aelfjnalfjenaef
NicolasHug Nov 20, 2024
21ce0e7
Merge branch 'main' into aelfjnalfjenaef
NicolasHug Nov 26, 2024
cb3bd78
Don't build webp support on rocm
NicolasHug Nov 27, 2024
a4e53eb
Switch unit test back to Manylinux2014
atalman Nov 27, 2024
c32adc8
Merge branch 'main' into fix_vision_unit_test
NicolasHug Nov 27, 2024
51f3c92
Merge branch 'main' into fix_vision_unit_test
atalman Nov 28, 2024
7739bea
Merge branch 'main' into fix_vision_unit_test
atalman Nov 28, 2024
8d1be3d
Merge branch 'main' into fix_vision_unit_test
NicolasHug Nov 28, 2024
8526117
Merge branch 'main' into fix_vision_unit_test
atalman Nov 29, 2024
a431819
Merge branch 'main' of github.com:pytorch/vision into aelfjnalfjenaef
NicolasHug Nov 29, 2024
3ad8da8
Merge branch 'fix_vision_unit_test' into aelfjnalfjenaef
NicolasHug Nov 29, 2024
d343a0f
only test images
NicolasHug Nov 29, 2024
e5e1693
Merge branch 'main' into aelfjnalfjenaef
NicolasHug Nov 29, 2024
8de061b
Merge branch 'main' into aelfjnalfjenaef
NicolasHug Dec 2, 2024
a4bb341
include types.h???
NicolasHug Dec 2, 2024
56e109b
Merge branch 'aelfjnalfjenaef' of github.com:nicolashug/vision into a…
NicolasHug Dec 2, 2024
7e4351a
Try different way to install libwebp????
NicolasHug Dec 2, 2024
4f074a3
aefaef
NicolasHug Dec 2, 2024
1af8d4b
AAAAAAAAAAAAAAAAH
NicolasHug Dec 2, 2024
77f2e23
aelfnjljnaef
NicolasHug Dec 2, 2024
1e3822c
Remove ROCM-specific stuff?
NicolasHug Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packaging/pre_build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ else
conda install -yq ffmpeg=4.2 libjpeg-turbo -c pytorch-nightly
fi

yum install -y libjpeg-turbo-devel libwebp-devel freetype gnutls
conda install libwebp -yq
conda install libjpeg-turbo -c pytorch
yum install -y freetype gnutls
pip install auditwheel
fi

Expand Down
2 changes: 2 additions & 0 deletions test/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
IS_MACOS = sys.platform == "darwin"
PILLOW_VERSION = tuple(int(x) for x in PILLOW_VERSION.split("."))
WEBP_TEST_IMAGES_DIR = os.environ.get("WEBP_TEST_IMAGES_DIR", "")
# See https://github.com/pytorch/vision/pull/8724#issuecomment-2503964558
ROCM_WEBP_MESSAGE = "ROCM not built with webp support."

# Hacky way of figuring out whether we compiled with libavif/libheif (those are
# currenlty disabled by default)
Expand Down
5 changes: 4 additions & 1 deletion torchvision/csrc/io/image/cpu/decode_webp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#if WEBP_FOUND
#include "webp/decode.h"
#include "webp/types.h"
#endif // WEBP_FOUND

namespace vision {
Expand Down Expand Up @@ -44,10 +45,12 @@ torch::Tensor decode_webp(

auto decoded_data =
decoding_func(encoded_data_p, encoded_data_size, &width, &height);

TORCH_CHECK(decoded_data != nullptr, "WebPDecodeRGB[A] failed.");

auto deleter = [decoded_data](void*) { WebPFree(decoded_data); };
auto out = torch::from_blob(
decoded_data, {height, width, num_channels}, torch::kUInt8);
decoded_data, {height, width, num_channels}, deleter, torch::kUInt8);

return out.permute({2, 0, 1});
}
Expand Down
Loading