Skip to content

Commit 2bd64ca

Browse files
committed
Merge branch 'main' of github.com:pytorch/vision into extra_decoders
2 parents 937f2ab + 8f8a195 commit 2bd64ca

File tree

15 files changed

+90
-17
lines changed

15 files changed

+90
-17
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
script: |
7373
set -euo pipefail
7474
75-
export PYTHON_VERSION=3.9
75+
export PYTHON_VERSION=3.11
7676
export GPU_ARCH_TYPE=cpu
7777
export GPU_ARCH_VERSION=''
7878
@@ -83,7 +83,7 @@ jobs:
8383
conda activate ci
8484
8585
echo '::group::Install lint tools'
86-
pip install --progress-bar=off mypy
86+
pip install --progress-bar=off "mypy==1.13.0"
8787
echo '::endgroup::'
8888
8989
echo '::group::Lint Python types'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ docs/source/auto_examples/
1616
docs/source/gen_modules/
1717
docs/source/generated/
1818
docs/source/models/generated/
19+
docs/source/sg_execution_times.rst
1920
# pytorch-sphinx-theme gets installed here
2021
docs/src
2122

@@ -42,3 +43,5 @@ xcuserdata/
4243
# direnv
4344
.direnv
4445
.envrc
46+
47+
scripts/release_notes/data.json

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_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/decoder/memory_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ DecoderInCallback MemoryBuffer::getCallback(
5454
MemoryBuffer object(buffer, size);
5555
return
5656
[object](uint8_t* out, int size, int whence, uint64_t timeoutMs) mutable
57-
-> int {
57+
-> int {
5858
if (out) { // see defs.h file
5959
// read mode
6060
return object.read(out, size);

torchvision/csrc/io/decoder/sync_decoder_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ TEST(SyncDecoder, TestMemoryBufferNoSeekableWithFullRead) {
361361
CHECK(decoder.init(
362362
params,
363363
[object](uint8_t* out, int size, int whence, uint64_t timeoutMs) mutable
364-
-> int {
364+
-> int {
365365
if (out) { // see defs.h file
366366
// read mode
367367
return object.read(out, size);
@@ -401,7 +401,7 @@ TEST(SyncDecoder, TestMemoryBufferNoSeekableWithPartialRead) {
401401
CHECK(!decoder.init(
402402
params,
403403
[object](uint8_t* out, int size, int whence, uint64_t timeoutMs) mutable
404-
-> int {
404+
-> int {
405405
if (out) { // see defs.h file
406406
// read mode
407407
return object.read(out, size);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) {
2828
C10_LOG_API_USAGE_ONCE(
2929
"torchvision.csrc.io.image.cpu.encode_jpeg.encode_jpeg");
3030
// Define compression structures and error handling
31-
struct jpeg_compress_struct cinfo {};
32-
struct torch_jpeg_error_mgr jerr {};
31+
struct jpeg_compress_struct cinfo{};
32+
struct torch_jpeg_error_mgr jerr{};
3333

3434
// Define buffer to write JPEG information to and its size
3535
JpegSizeType jpegSize = 0;

0 commit comments

Comments
 (0)