Skip to content

Commit aee9bd1

Browse files
Merge branch 'main' into feature/different-label-background
2 parents 19ae698 + cdc1fee commit aee9bd1

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shutil
77
import subprocess
88
import sys
9+
import sysconfig
910
import warnings
1011
from pathlib import Path
1112

@@ -136,6 +137,8 @@ def get_macros_and_flags():
136137
if sys.platform == "win32":
137138
define_macros += [("torchvision_EXPORTS", None)]
138139
extra_compile_args["cxx"].append("/MP")
140+
if sysconfig.get_config_var("Py_GIL_DISABLED"):
141+
extra_compile_args["cxx"].append("-DPy_GIL_DISABLED")
139142

140143
if DEBUG:
141144
extra_compile_args["cxx"].append("-g")

torchvision/datasets/caltech.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import os
22
import os.path
3+
import shutil
34
from pathlib import Path
45
from typing import Any, Callable, Optional, Union
56

67
from PIL import Image
78

8-
from .utils import download_and_extract_archive, verify_str_arg
9+
from .utils import download_and_extract_archive, extract_archive, verify_str_arg
910
from .vision import VisionDataset
1011

1112

@@ -133,17 +134,17 @@ def download(self) -> None:
133134
return
134135

135136
download_and_extract_archive(
136-
"https://drive.google.com/file/d/137RyRjvTBkBiIfeYBNZBtViDHQ6_Ewsp",
137-
self.root,
138-
filename="101_ObjectCategories.tar.gz",
139-
md5="b224c7392d521a49829488ab0f1120d9",
140-
)
141-
download_and_extract_archive(
142-
"https://drive.google.com/file/d/175kQy3UsZ0wUEHZjqkUDdNVssr7bgh_m",
143-
self.root,
144-
filename="Annotations.tar",
145-
md5="6f83eeb1f24d99cab4eb377263132c91",
137+
"https://data.caltech.edu/records/mzrjq-6wc02/files/caltech-101.zip",
138+
download_root=self.root,
139+
filename="caltech-101.zip",
140+
md5="3138e1922a9193bfa496528edbbc45d0",
146141
)
142+
gzip_folder = os.path.join(self.root, "caltech-101")
143+
for gzip_file in os.listdir(gzip_folder):
144+
if gzip_file.endswith(".gz"):
145+
extract_archive(os.path.join(gzip_folder, gzip_file), self.root)
146+
shutil.rmtree(gzip_folder)
147+
os.remove(os.path.join(self.root, "caltech-101.zip"))
147148

148149
def extra_repr(self) -> str:
149150
return "Target type: {target_type}".format(**self.__dict__)
@@ -233,7 +234,7 @@ def download(self) -> None:
233234
return
234235

235236
download_and_extract_archive(
236-
"https://drive.google.com/file/d/1r6o0pSROcV1_VwT4oSjA2FBUSCWGuxLK",
237+
"https://data.caltech.edu/records/nyy15-4j048/files/256_ObjectCategories.tar",
237238
self.root,
238239
filename="256_ObjectCategories.tar",
239240
md5="67b4f42ca05d46448c6bb8ecd2220f6d",

torchvision/ops/drop_block.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def drop_block2d(
3636

3737
N, C, H, W = input.size()
3838
block_size = min(block_size, W, H)
39+
if block_size % 2 == 0:
40+
raise ValueError(f"block size should be odd. Got {block_size} which is even.")
41+
3942
# compute the gamma of Bernoulli distribution
4043
gamma = (p * H * W) / ((block_size**2) * ((H - block_size + 1) * (W - block_size + 1)))
4144
noise = torch.empty((N, C, H - block_size + 1, W - block_size + 1), dtype=input.dtype, device=input.device)
@@ -82,6 +85,9 @@ def drop_block3d(
8285

8386
N, C, D, H, W = input.size()
8487
block_size = min(block_size, D, H, W)
88+
if block_size % 2 == 0:
89+
raise ValueError(f"block size should be odd. Got {block_size} which is even.")
90+
8591
# compute the gamma of Bernoulli distribution
8692
gamma = (p * D * H * W) / ((block_size**3) * ((D - block_size + 1) * (H - block_size + 1) * (W - block_size + 1)))
8793
noise = torch.empty(

0 commit comments

Comments
 (0)