Skip to content

Commit bfdb356

Browse files
authored
Merge branch 'main' into 313
2 parents 615f5fc + 6279faa commit bfdb356

File tree

14 files changed

+106
-19
lines changed

14 files changed

+106
-19
lines changed

.github/workflows/prototype-tests-linux-gpu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
gpu-arch-type: cuda
2424
gpu-arch-version: "11.8"
2525
fail-fast: false
26-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
26+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
2727
with:
2828
repository: pytorch/vision
2929
runner: ${{ matrix.runner }}

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
gpu-arch-type: cuda
2828
gpu-arch-version: "11.8"
2929
fail-fast: false
30-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
30+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
3131
with:
3232
repository: pytorch/vision
3333
runner: ${{ matrix.runner }}
@@ -107,7 +107,7 @@ jobs:
107107
./.github/scripts/unittest.sh
108108
109109
onnx:
110-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
110+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
111111
with:
112112
repository: pytorch/vision
113113
test-infra-ref: main
@@ -138,7 +138,7 @@ jobs:
138138
echo '::endgroup::'
139139
140140
unittests-extended:
141-
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
141+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
142142
if: contains(github.event.pull_request.labels.*.name, 'run-extended')
143143
with:
144144
repository: pytorch/vision

packaging/pre_build_script.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ else
3232
conda install -yq ffmpeg=4.2 libjpeg-turbo -c pytorch-nightly
3333
fi
3434

35-
yum install -y libjpeg-turbo-devel libwebp-devel freetype gnutls
35+
conda install libwebp -yq
36+
conda install libjpeg-turbo -c pytorch
37+
yum install -y freetype gnutls
3638
pip install auditwheel
3739
fi
3840

references/depth/stereo/utils/losses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def make_gaussian_kernel(kernel_size: int, sigma: float) -> torch.Tensor:
1313
y = torch.arange(kernel_size, dtype=torch.float32)
1414
x = x - (kernel_size - 1) / 2
1515
y = y - (kernel_size - 1) / 2
16-
x, y = torch.meshgrid(x, y)
16+
x, y = torch.meshgrid(x, y, indexing="ij")
1717
grid = (x**2 + y**2) / (2 * sigma**2)
1818
kernel = torch.exp(-grid)
1919
kernel = kernel / kernel.sum()

references/video_classification/train.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def main(args):
164164

165165
if args.cache_dataset and os.path.exists(cache_path):
166166
print(f"Loading dataset_train from {cache_path}")
167-
dataset, _ = torch.load(cache_path, weights_only=True)
167+
dataset, _ = torch.load(cache_path, weights_only=False)
168168
dataset.transform = transform_train
169169
else:
170170
if args.distributed:
@@ -201,7 +201,7 @@ def main(args):
201201

202202
if args.cache_dataset and os.path.exists(cache_path):
203203
print(f"Loading dataset_test from {cache_path}")
204-
dataset_test, _ = torch.load(cache_path, weights_only=True)
204+
dataset_test, _ = torch.load(cache_path, weights_only=False)
205205
dataset_test.transform = transform_test
206206
else:
207207
if args.distributed:
723 Bytes
Loading

test/test_backbone_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import random
2+
from copy import deepcopy
23
from itertools import chain
34
from typing import Mapping, Sequence
45

@@ -322,3 +323,14 @@ def forward(self, x):
322323
out = model(self.inp)
323324
# And backward
324325
out["leaf_module"].float().mean().backward()
326+
327+
def test_deepcopy(self):
328+
# Non-regression test for https://github.com/pytorch/vision/issues/8634
329+
model = models.efficientnet_b3(weights=None)
330+
extractor = create_feature_extractor(model=model, return_nodes={"classifier.0": "out"})
331+
332+
extractor.eval()
333+
extractor.train()
334+
extractor = deepcopy(extractor)
335+
extractor.eval()
336+
extractor.train()

test/test_image.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
IS_MACOS = sys.platform == "darwin"
4646
PILLOW_VERSION = tuple(int(x) for x in PILLOW_VERSION.split("."))
4747
WEBP_TEST_IMAGES_DIR = os.environ.get("WEBP_TEST_IMAGES_DIR", "")
48+
# See https://github.com/pytorch/vision/pull/8724#issuecomment-2503964558
49+
ROCM_WEBP_MESSAGE = "ROCM not built with webp support."
4850

4951
# Hacky way of figuring out whether we compiled with libavif/libheif (those are
5052
# currenlty disabled by default)

test/test_utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ def test_draw_boxes():
116116
assert_equal(img, img_cp)
117117

118118

119+
@pytest.mark.skipif(PILLOW_VERSION < (10, 1), reason="The reference image is only valid for PIL >= 10.1")
120+
def test_draw_boxes_with_coloured_labels():
121+
img = torch.full((3, 100, 100), 255, dtype=torch.uint8)
122+
labels = ["a", "b", "c", "d"]
123+
colors = ["green", "#FF00FF", (0, 255, 0), "red"]
124+
label_colors = ["green", "red", (0, 255, 0), "#FF00FF"]
125+
result = utils.draw_bounding_boxes(img, boxes, labels=labels, colors=colors, fill=True, label_colors=label_colors)
126+
127+
path = os.path.join(
128+
os.path.dirname(os.path.abspath(__file__)), "assets", "fakedata", "draw_boxes_different_label_colors.png"
129+
)
130+
expected = torch.as_tensor(np.array(Image.open(path))).permute(2, 0, 1)
131+
assert_equal(result, expected)
132+
133+
119134
@pytest.mark.parametrize("fill", [True, False])
120135
def test_draw_boxes_dtypes(fill):
121136
img_uint8 = torch.full((3, 100, 100), 255, dtype=torch.uint8)

torchvision/csrc/io/image/cpu/decode_webp.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#if WEBP_FOUND
55
#include "webp/decode.h"
6+
#include "webp/types.h"
67
#endif // WEBP_FOUND
78

89
namespace vision {
@@ -44,10 +45,12 @@ torch::Tensor decode_webp(
4445

4546
auto decoded_data =
4647
decoding_func(encoded_data_p, encoded_data_size, &width, &height);
48+
4749
TORCH_CHECK(decoded_data != nullptr, "WebPDecodeRGB[A] failed.");
4850

51+
auto deleter = [decoded_data](void*) { WebPFree(decoded_data); };
4952
auto out = torch::from_blob(
50-
decoded_data, {height, width, num_channels}, torch::kUInt8);
53+
decoded_data, {height, width, num_channels}, deleter, torch::kUInt8);
5154

5255
return out.permute({2, 0, 1});
5356
}

0 commit comments

Comments
 (0)