Skip to content

Commit 5a2f419

Browse files
committed
Merge branch 'main' of github.com:pytorch/vision into docs_io
2 parents 032477b + f559edf commit 5a2f419

File tree

8 files changed

+27
-3
lines changed

8 files changed

+27
-3
lines changed

.github/workflows/build-wheels-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
os: windows
2626
test-infra-repository: pytorch/test-infra
2727
test-infra-ref: main
28+
with-xpu: enable
2829
build:
2930
needs: generate-matrix
3031
strategy:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ versions.
2121
| `torch` | `torchvision` | Python |
2222
| ------------------ | ------------------ | ------------------- |
2323
| `main` / `nightly` | `main` / `nightly` | `>=3.9`, `<=3.12` |
24+
| `2.5` | `0.20` | `>=3.9`, `<=3.12` |
2425
| `2.4` | `0.19` | `>=3.8`, `<=3.12` |
2526
| `2.3` | `0.18` | `>=3.8`, `<=3.12` |
2627
| `2.2` | `0.17` | `>=3.8`, `<=3.11` |

packaging/windows/internal/vc_env_helper.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ if "%VSDEVCMD_ARGS%" == "" (
2828

2929
@echo on
3030

31+
if "%CU_VERSION%" == "xpu" call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
32+
3133
set DISTUTILS_USE_SDK=1
3234

3335
set args=%1

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def make_image_extension():
366366
else:
367367
warnings.warn("Building torchvision without AVIF support")
368368

369-
if USE_NVJPEG and torch.cuda.is_available():
369+
if USE_NVJPEG and (torch.cuda.is_available() or FORCE_CUDA):
370370
nvjpeg_found = CUDA_HOME is not None and (Path(CUDA_HOME) / "include/nvjpeg.h").exists()
371371

372372
if nvjpeg_found:
@@ -376,6 +376,8 @@ def make_image_extension():
376376
Extension = CUDAExtension
377377
else:
378378
warnings.warn("Building torchvision without NVJPEG support")
379+
elif USE_NVJPEG:
380+
warnings.warn("Building torchvision without NVJPEG support")
379381

380382
return Extension(
381383
name="torchvision.image",

test/test_image.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import re
66
import sys
7+
from contextlib import nullcontext
78
from pathlib import Path
89

910
import numpy as np
@@ -13,6 +14,7 @@
1314
import torchvision.transforms.v2.functional as F
1415
from common_utils import assert_equal, cpu_and_cuda, IN_OSS_CI, needs_cuda
1516
from PIL import __version__ as PILLOW_VERSION, Image, ImageOps, ImageSequence
17+
from torchvision._internally_replaced_utils import IN_FBCODE
1618
from torchvision.io.image import (
1719
_decode_avif,
1820
_decode_heic,
@@ -1076,5 +1078,13 @@ def test_mode_str():
10761078
assert decode_image(path, mode="RGBA").shape[0] == 4
10771079

10781080

1081+
def test_avif_heic_fbcode():
1082+
cm = nullcontext() if IN_FBCODE else pytest.raises(ImportError, match="cannot import")
1083+
with cm:
1084+
from torchvision.io import decode_heic # noqa
1085+
with cm:
1086+
from torchvision.io import decode_avif # noqa
1087+
1088+
10791089
if __name__ == "__main__":
10801090
pytest.main([__file__])

torchvision/_internally_replaced_utils.py

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

77
_HOME = os.path.join(_get_torch_home(), "datasets", "vision")
88
_USE_SHARDED_DATASETS = False
9+
IN_FBCODE = False
910

1011

1112
def _download_file_from_remote_location(fpath: str, url: str) -> None:

torchvision/io/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,10 @@
7474
"Video",
7575
"VideoReader",
7676
]
77+
78+
from .._internally_replaced_utils import IN_FBCODE
79+
80+
if IN_FBCODE:
81+
from .image import _decode_avif as decode_avif, _decode_heic as decode_heic
82+
83+
__all__ += ["decode_avif", "decode_heic"]

torchvision/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,9 @@ def _parse_colors(
604604
f"Number of colors must be equal or larger than the number of objects, but got {len(colors)} < {num_objects}."
605605
)
606606
elif not isinstance(colors, (tuple, str)):
607-
raise ValueError("`colors` must be a tuple or a string, or a list thereof, but got {colors}.")
607+
raise ValueError(f"`colors` must be a tuple or a string, or a list thereof, but got {colors}.")
608608
elif isinstance(colors, tuple) and len(colors) != 3:
609-
raise ValueError("If passed as tuple, colors should be an RGB triplet, but got {colors}.")
609+
raise ValueError(f"If passed as tuple, colors should be an RGB triplet, but got {colors}.")
610610
else: # colors specifies a single color for all objects
611611
colors = [colors] * num_objects
612612

0 commit comments

Comments
 (0)