Skip to content

Commit 6cb192c

Browse files
author
pytorchbot
committed
2024-11-08 nightly release (4249b61)
1 parent b801d7a commit 6cb192c

File tree

5 files changed

+9
-21
lines changed

5 files changed

+9
-21
lines changed

test/test_datasets.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,11 +1869,6 @@ def test_class_to_idx(self):
18691869
with self.create_dataset() as (dataset, _):
18701870
assert dataset.class_to_idx == class_to_idx
18711871

1872-
def test_images_download_preexisting(self):
1873-
with pytest.raises(RuntimeError):
1874-
with self.create_dataset({"download": True}):
1875-
pass
1876-
18771872

18781873
class INaturalistTestCase(datasets_utils.ImageDatasetTestCase):
18791874
DATASET_CLASS = datasets.INaturalist

torchvision/csrc/io/image/cpu/decode_webp.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ torch::Tensor decode_webp(
4444

4545
auto decoded_data =
4646
decoding_func(encoded_data_p, encoded_data_size, &width, &height);
47+
4748
TORCH_CHECK(decoded_data != nullptr, "WebPDecodeRGB[A] failed.");
4849

50+
auto deleter = [decoded_data](void*) { WebPFree(decoded_data); };
4951
auto out = torch::from_blob(
50-
decoded_data, {height, width, num_channels}, torch::kUInt8);
52+
decoded_data, {height, width, num_channels}, deleter, torch::kUInt8);
5153

5254
return out.permute({2, 0, 1});
5355
}

torchvision/datasets/inaturalist.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(
8181
if download:
8282
self.download()
8383

84-
if not self._check_integrity():
84+
if not self._check_exists():
8585
raise RuntimeError("Dataset not found or corrupted. You can use download=True to download it")
8686

8787
self.all_categories: List[str] = []
@@ -219,15 +219,12 @@ def category_name(self, category_type: str, category_id: int) -> str:
219219
return name
220220
raise ValueError(f"Invalid category id {category_id} for {category_type}")
221221

222-
def _check_integrity(self) -> bool:
222+
def _check_exists(self) -> bool:
223223
return os.path.exists(self.root) and len(os.listdir(self.root)) > 0
224224

225225
def download(self) -> None:
226-
if self._check_integrity():
227-
raise RuntimeError(
228-
f"The directory {self.root} already exists. "
229-
f"If you want to re-download or re-extract the images, delete the directory."
230-
)
226+
if self._check_exists():
227+
return
231228

232229
base_root = os.path.dirname(self.root)
233230

torchvision/datasets/kinetics.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ def _download_videos(self) -> None:
166166
RuntimeError: if download folder exists, break to prevent downloading entire dataset again.
167167
"""
168168
if path.exists(self.split_folder):
169-
raise RuntimeError(
170-
f"The directory {self.split_folder} already exists. "
171-
f"If you want to re-download or re-extract the images, delete the directory."
172-
)
169+
return
173170
tar_path = path.join(self.root, "tars")
174171
file_list_path = path.join(self.root, "files")
175172

torchvision/datasets/places365.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,7 @@ def download_devkit(self) -> None:
145145

146146
def download_images(self) -> None:
147147
if path.exists(self.images_dir):
148-
raise RuntimeError(
149-
f"The directory {self.images_dir} already exists. If you want to re-download or re-extract the images, "
150-
f"delete the directory."
151-
)
148+
return
152149

153150
file, md5 = self._IMAGES_META[(self.split, self.small)]
154151
download_and_extract_archive(urljoin(self._BASE_URL, file), self.root, md5=md5)

0 commit comments

Comments
 (0)