Skip to content

Commit

Permalink
Merge branch 'main' into please_dont_modify_this_branch_unless_you_ar…
Browse files Browse the repository at this point in the history
…e_just_merging_with_main_
  • Loading branch information
NicolasHug authored Jul 30, 2024
2 parents a8e2f14 + 09077a8 commit 4cc12a7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,14 @@ def test_write_video_with_audio(self, device, tmpdir):
f_name = os.path.join(VIDEO_DIR, "R6llTwEh07w.mp4")
video_tensor, audio_tensor, info = io.read_video(f_name, pts_unit="sec")

video_tensor = video_tensor.to(device)
audio_tensor = audio_tensor.to(device)

out_f_name = os.path.join(tmpdir, "testing.mp4")
io.video.write_video(
out_f_name,
video_tensor,
video_tensor.to(device),
round(info["video_fps"]),
video_codec="libx264rgb",
options={"crf": "0"},
audio_array=audio_tensor,
audio_array=audio_tensor.to(device),
audio_fps=info["audio_fps"],
audio_codec="aac",
)
Expand Down
2 changes: 1 addition & 1 deletion torchvision/datasets/kinetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .vision import VisionDataset


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


Expand Down
2 changes: 1 addition & 1 deletion torchvision/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

def _urlretrieve(url: str, filename: Union[str, pathlib.Path], chunk_size: int = 1024 * 32) -> None:
with urllib.request.urlopen(urllib.request.Request(url, headers={"User-Agent": USER_AGENT})) as response:
with open(filename, "wb") as fh, tqdm(total=response.length) as pbar:
with open(filename, "wb") as fh, tqdm(total=response.length, unit="B", unit_scale=True) as pbar:
while chunk := response.read(chunk_size):
fh.write(chunk)
pbar.update(len(chunk))
Expand Down
2 changes: 1 addition & 1 deletion torchvision/io/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def write_video(
audio_sample_fmt = container.streams.audio[0].format.name

format_dtype = np.dtype(audio_format_dtypes[audio_sample_fmt])
audio_array = torch.as_tensor(audio_array).numpy().astype(format_dtype)
audio_array = torch.as_tensor(audio_array).numpy(force=True).astype(format_dtype)

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

Expand Down
4 changes: 2 additions & 2 deletions torchvision/transforms/_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This file is part of the private API. Please do not use directly these classes as they will be modified on
future versions without warning. The classes should be accessed only via the transforms argument of Weights.
"""
from typing import Optional, Tuple
from typing import Optional, Tuple, Union

import torch
from torch import nn, Tensor
Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(
self,
*,
crop_size: Tuple[int, int],
resize_size: Tuple[int, int],
resize_size: Union[Tuple[int], Tuple[int, int]],
mean: Tuple[float, ...] = (0.43216, 0.394666, 0.37645),
std: Tuple[float, ...] = (0.22803, 0.22145, 0.216989),
interpolation: InterpolationMode = InterpolationMode.BILINEAR,
Expand Down

0 comments on commit 4cc12a7

Please sign in to comment.