Skip to content

Commit 25e6fc7

Browse files
authored
Merge branch 'main' into wrappp
2 parents b1018a9 + f2b6f43 commit 25e6fc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+415
-392
lines changed

.github/scripts/setup-env.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ conda create \
4040
--quiet --yes \
4141
python="${PYTHON_VERSION}" pip \
4242
ninja cmake \
43-
libpng jpeg \
43+
libpng \
4444
'ffmpeg<4.3'
4545
conda activate ci
46+
conda install --quiet --yes libjpeg-turbo -c pytorch
4647
pip install --progress-bar=off --upgrade setuptools
4748

4849
# See https://github.com/pytorch/vision/issues/6790

.github/scripts/unittest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ echo '::group::Install testing utilities'
1111
pip install --progress-bar=off pytest pytest-mock pytest-cov
1212
echo '::endgroup::'
1313

14+
python test/smoke_test.py
1415
pytest --junit-xml="${RUNNER_TEST_RESULTS_DIR}/test-results.xml" -v --durations=25

docs/source/transforms.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Color
155155

156156
ColorJitter
157157
v2.ColorJitter
158+
v2.RandomChannelPermutation
158159
v2.RandomPhotometricDistort
159160
Grayscale
160161
v2.Grayscale

packaging/pre_build_script.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fi
1313

1414
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
1515
# Install libpng from Anaconda (defaults)
16-
conda install libpng "jpeg<=9b" -yq
17-
conda install -yq ffmpeg=4.2 -c pytorch
16+
conda install libpng -yq
17+
conda install -yq ffmpeg=4.2 libjpeg-turbo -c pytorch
1818

1919
# Copy binaries to be included in the wheel distribution
2020
if [[ "$OSTYPE" == "msys" ]]; then

packaging/torchvision/meta.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ requirements:
1010
build:
1111
- {{ compiler('c') }} # [win]
1212
- libpng
13-
- jpeg
13+
- libjpeg-turbo
1414
# NOTE: The only ffmpeg version that we build is actually 4.2
1515
- ffmpeg >=4.2 # [not win]
1616

@@ -28,7 +28,7 @@ requirements:
2828
- requests
2929
- libpng
3030
- ffmpeg >=4.2 # [not win]
31-
- jpeg
31+
- libjpeg-turbo
3232
- pillow >=5.3.0, !=8.3.*
3333
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
3434
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
@@ -62,7 +62,7 @@ test:
6262
requires:
6363
- pytest
6464
- scipy
65-
- jpeg
65+
- libjpeg-turbo
6666
- ca-certificates
6767

6868

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ addopts =
33
# show tests that (f)ailed, (E)rror, or (X)passed in the summary
44
-rfEX
55
# Make tracebacks shorter
6-
--tb=native
6+
--tb=short
77
# enable all warnings
88
-Wd
99
--ignore=test/test_datasets_download.py

test/common_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ def make_bounding_box_loader(*, extra_dims=(), format, spatial_size=DEFAULT_PORT
691691
if isinstance(format, str):
692692
format = datapoints.BoundingBoxFormat[format]
693693

694-
spatial_size = _parse_size(spatial_size, name="canvas_size")
694+
spatial_size = _parse_size(spatial_size, name="spatial_size")
695695

696696
def fn(shape, dtype, device):
697697
*batch_dims, num_coordinates = shape
@@ -702,12 +702,12 @@ def fn(shape, dtype, device):
702702
format=format, canvas_size=spatial_size, batch_dims=batch_dims, dtype=dtype, device=device
703703
)
704704

705-
return BoundingBoxesLoader(fn, shape=(*extra_dims, 4), dtype=dtype, format=format, spatial_size=spatial_size)
705+
return BoundingBoxesLoader(fn, shape=(*extra_dims[-1:], 4), dtype=dtype, format=format, spatial_size=spatial_size)
706706

707707

708708
def make_bounding_box_loaders(
709709
*,
710-
extra_dims=DEFAULT_EXTRA_DIMS,
710+
extra_dims=tuple(d for d in DEFAULT_EXTRA_DIMS if len(d) < 2),
711711
formats=tuple(datapoints.BoundingBoxFormat),
712712
spatial_size=DEFAULT_PORTRAIT_SPATIAL_SIZE,
713713
dtypes=(torch.float32, torch.float64, torch.int64),

test/smoke_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def smoke_test_torchvision_resnet50_classify(device: str = "cpu") -> None:
7878
def main() -> None:
7979
print(f"torchvision: {torchvision.__version__}")
8080
print(f"torch.cuda.is_available: {torch.cuda.is_available()}")
81+
print(f"{torch.ops.image._jpeg_version() = }")
82+
assert torch.ops.image._is_compiled_against_turbo()
8183
smoke_test_torchvision()
8284
smoke_test_torchvision_read_decode()
8385
smoke_test_torchvision_resnet50_classify()

test/test_datapoints.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_mask_instance(data):
2222
assert mask.ndim == 3 and mask.shape[0] == 1
2323

2424

25-
@pytest.mark.parametrize("data", [torch.randint(0, 32, size=(5, 4)), [[0, 0, 5, 5], [2, 2, 7, 7]]])
25+
@pytest.mark.parametrize("data", [torch.randint(0, 32, size=(5, 4)), [[0, 0, 5, 5], [2, 2, 7, 7]], [1, 2, 3, 4]])
2626
@pytest.mark.parametrize(
2727
"format", ["XYXY", "CXCYWH", datapoints.BoundingBoxFormat.XYXY, datapoints.BoundingBoxFormat.XYWH]
2828
)
@@ -35,6 +35,12 @@ def test_bbox_instance(data, format):
3535
assert bboxes.format == format
3636

3737

38+
def test_bbox_dim_error():
39+
data_3d = [[[1, 2, 3, 4]]]
40+
with pytest.raises(ValueError, match="Expected a 1D or 2D tensor, got 3D"):
41+
datapoints.BoundingBoxes(data_3d, format="XYXY", canvas_size=(32, 32))
42+
43+
3844
@pytest.mark.parametrize(
3945
("data", "input_requires_grad", "expected_requires_grad"),
4046
[

test/test_prototype_transforms.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from torchvision.datapoints import BoundingBoxes, BoundingBoxFormat, Image, Mask, Video
2121
from torchvision.prototype import datapoints, transforms
2222
from torchvision.transforms.v2._utils import _convert_fill_arg
23-
from torchvision.transforms.v2.functional import InterpolationMode, pil_to_tensor, to_image_pil
23+
from torchvision.transforms.v2.functional import clamp_bounding_boxes, InterpolationMode, pil_to_tensor, to_image_pil
2424
from torchvision.transforms.v2.utils import check_type, is_simple_tensor
2525

2626
BATCH_EXTRA_DIMS = [extra_dims for extra_dims in DEFAULT_EXTRA_DIMS if extra_dims]
@@ -306,7 +306,9 @@ def test__transform_bounding_boxes_clamping(self, mocker):
306306
bounding_boxes = make_bounding_box(
307307
format=BoundingBoxFormat.XYXY, canvas_size=canvas_size, batch_dims=(batch_size,)
308308
)
309-
mock = mocker.patch("torchvision.prototype.transforms._geometry.F.clamp_bounding_boxes")
309+
mock = mocker.patch(
310+
"torchvision.prototype.transforms._geometry.F.clamp_bounding_boxes", wraps=clamp_bounding_boxes
311+
)
310312

311313
transform = transforms.FixedSizeCrop((-1, -1))
312314
mocker.patch("torchvision.prototype.transforms._geometry.has_any", return_value=True)

0 commit comments

Comments
 (0)