Skip to content

Commit 2cbf109

Browse files
author
pytorchbot
committed
2025-05-29 nightly release (9813fd6)
1 parent de27b52 commit 2cbf109

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
NVCC_FLAGS = os.getenv("NVCC_FLAGS", None)
2525
# Note: the GPU video decoding stuff used to be called "video codec", which
2626
# isn't an accurate or descriptive name considering there are at least 2 other
27-
# video deocding backends in torchvision. I'm renaming this to "gpu video
27+
# video decoding backends in torchvision. I'm renaming this to "gpu video
2828
# decoder" where possible, keeping user facing names (like the env var below) to
2929
# the old scheme for BC.
3030
USE_GPU_VIDEO_DECODER = os.getenv("TORCHVISION_USE_VIDEO_CODEC", "1") == "1"
@@ -211,7 +211,7 @@ def find_libpng():
211211
subprocess.run([libpng_config, "--version"], stdout=subprocess.PIPE).stdout.strip().decode("utf-8")
212212
)
213213
if png_version < min_version:
214-
warnings.warn("libpng version {png_version} is less than minimum required version {min_version}")
214+
warnings.warn(f"libpng version {png_version} is less than minimum required version {min_version}")
215215
return False, None, None, None
216216

217217
include_dir = (
@@ -448,7 +448,7 @@ def find_ffmpeg_libraries():
448448

449449
extensions.append(
450450
CppExtension(
451-
# This is an aweful name. It should be "cpu_video_decoder". Keeping for BC.
451+
# This is an awful name. It should be "cpu_video_decoder". Keeping for BC.
452452
"torchvision.video_reader",
453453
combined_src,
454454
include_dirs=[

torchvision/models/detection/anchor_utils.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,16 @@ def generate_anchors(
7474
return base_anchors.round()
7575

7676
def set_cell_anchors(self, dtype: torch.dtype, device: torch.device):
77-
return [cell_anchor.to(dtype=dtype, device=device) for cell_anchor in self.cell_anchors]
77+
self.cell_anchors = [cell_anchor.to(dtype=dtype, device=device) for cell_anchor in self.cell_anchors]
7878

7979
def num_anchors_per_location(self) -> list[int]:
8080
return [len(s) * len(a) for s, a in zip(self.sizes, self.aspect_ratios)]
8181

8282
# For every combination of (a, (g, s), i) in (self.cell_anchors, zip(grid_sizes, strides), 0:2),
8383
# output g[i] anchors that are s[i] distance apart in direction i, with the same dimensions as a.
84-
def grid_anchors(
85-
self,
86-
grid_sizes: list[list[int]],
87-
strides: list[list[Tensor]],
88-
cell_anchors: list[torch.Tensor],
89-
) -> list[Tensor]:
84+
def grid_anchors(self, grid_sizes: list[list[int]], strides: list[list[Tensor]]) -> list[Tensor]:
9085
anchors = []
86+
cell_anchors = self.cell_anchors
9187
torch._assert(cell_anchors is not None, "cell_anchors should not be None")
9288
torch._assert(
9389
len(grid_sizes) == len(strides) == len(cell_anchors),
@@ -127,8 +123,8 @@ def forward(self, image_list: ImageList, feature_maps: list[Tensor]) -> list[Ten
127123
]
128124
for g in grid_sizes
129125
]
130-
cell_anchors = self.set_cell_anchors(dtype, device)
131-
anchors_over_all_feature_maps = self.grid_anchors(grid_sizes, strides, cell_anchors)
126+
self.set_cell_anchors(dtype, device)
127+
anchors_over_all_feature_maps = self.grid_anchors(grid_sizes, strides)
132128
anchors: list[list[torch.Tensor]] = []
133129
for _ in range(len(image_list.image_sizes)):
134130
anchors_in_image = [anchors_per_feature_map for anchors_per_feature_map in anchors_over_all_feature_maps]

0 commit comments

Comments
 (0)