Skip to content

Commit 9ef9377

Browse files
authored
Merge branch 'main' into fy/autocast-xpu
2 parents df4cedd + 61bd547 commit 9ef9377

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

packaging/torchvision/meta.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ requirements:
1111
- {{ compiler('c') }} # [win]
1212
- libpng
1313
- libjpeg-turbo
14-
- ffmpeg >=4.2 # [linux]
14+
- ffmpeg >=4.2.2, <5.0.0 # [linux]
1515

1616
host:
1717
- python
1818
- setuptools
1919
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
20-
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT') }}
20+
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT', 'pytorch') }}
2121
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
2222

2323
run:
@@ -26,11 +26,11 @@ requirements:
2626
- numpy >=1.23.5 # [py >= 311]
2727
- requests
2828
- libpng
29-
- ffmpeg >=4.2 # [linux]
29+
- ffmpeg >=4.2.2, <5.0.0 # [linux]
3030
- libjpeg-turbo
3131
- pillow >=5.3.0, !=8.3.*
3232
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
33-
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
33+
{{ environ.get('CONDA_PYTORCH_CONSTRAINT', 'pytorch') }}
3434
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
3535

3636
{% if build_variant == 'cpu' %}

test/test_io.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77
import torch
88
import torchvision.io as io
9-
from common_utils import assert_equal
9+
from common_utils import assert_equal, cpu_and_cuda
1010
from torchvision import get_video_backend
1111

1212

@@ -255,22 +255,19 @@ def test_read_video_partially_corrupted_file(self):
255255
assert_equal(video, data)
256256

257257
@pytest.mark.skipif(sys.platform == "win32", reason="temporarily disabled on Windows")
258-
@pytest.mark.parametrize("device", ["cpu", "cuda"])
258+
@pytest.mark.parametrize("device", cpu_and_cuda())
259259
def test_write_video_with_audio(self, device, tmpdir):
260260
f_name = os.path.join(VIDEO_DIR, "R6llTwEh07w.mp4")
261261
video_tensor, audio_tensor, info = io.read_video(f_name, pts_unit="sec")
262262

263-
video_tensor = video_tensor.to(device)
264-
audio_tensor = audio_tensor.to(device)
265-
266263
out_f_name = os.path.join(tmpdir, "testing.mp4")
267264
io.video.write_video(
268265
out_f_name,
269-
video_tensor,
266+
video_tensor.to(device),
270267
round(info["video_fps"]),
271268
video_codec="libx264rgb",
272269
options={"crf": "0"},
273-
audio_array=audio_tensor,
270+
audio_array=audio_tensor.to(device),
274271
audio_fps=info["audio_fps"],
275272
audio_codec="aac",
276273
)

torchvision/datasets/kinetics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .vision import VisionDataset
1717

1818

19-
def _dl_wrap(tarpath: str, videopath: str, line: str) -> None:
19+
def _dl_wrap(tarpath: Union[str, Path], videopath: Union[str, Path], line: str) -> None:
2020
download_and_extract_archive(line, tarpath, videopath)
2121

2222

torchvision/datasets/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
def _urlretrieve(url: str, filename: Union[str, pathlib.Path], chunk_size: int = 1024 * 32) -> None:
2828
with urllib.request.urlopen(urllib.request.Request(url, headers={"User-Agent": USER_AGENT})) as response:
29-
with open(filename, "wb") as fh, tqdm(total=response.length) as pbar:
29+
with open(filename, "wb") as fh, tqdm(total=response.length, unit="B", unit_scale=True) as pbar:
3030
while chunk := response.read(chunk_size):
3131
fh.write(chunk)
3232
pbar.update(len(chunk))

torchvision/io/video.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def write_video(
115115
audio_sample_fmt = container.streams.audio[0].format.name
116116

117117
format_dtype = np.dtype(audio_format_dtypes[audio_sample_fmt])
118-
audio_array = torch.as_tensor(audio_array).numpy().astype(format_dtype)
118+
audio_array = torch.as_tensor(audio_array).numpy(force=True).astype(format_dtype)
119119

120120
frame = av.AudioFrame.from_ndarray(audio_array, format=audio_sample_fmt, layout=audio_layout)
121121

torchvision/transforms/_presets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This file is part of the private API. Please do not use directly these classes as they will be modified on
33
future versions without warning. The classes should be accessed only via the transforms argument of Weights.
44
"""
5-
from typing import Optional, Tuple
5+
from typing import Optional, Tuple, Union
66

77
import torch
88
from torch import nn, Tensor
@@ -87,7 +87,7 @@ def __init__(
8787
self,
8888
*,
8989
crop_size: Tuple[int, int],
90-
resize_size: Tuple[int, int],
90+
resize_size: Union[Tuple[int], Tuple[int, int]],
9191
mean: Tuple[float, ...] = (0.43216, 0.394666, 0.37645),
9292
std: Tuple[float, ...] = (0.22803, 0.22145, 0.216989),
9393
interpolation: InterpolationMode = InterpolationMode.BILINEAR,

0 commit comments

Comments
 (0)