Skip to content

Commit cdc1fee

Browse files
hrsvrnAntoineSimoulinJonasKlotz
authored
Fixed Caltech-101 and Caltech-256 broken links with the official ones (#9205)
Co-authored-by: Antoine Simoulin <[email protected]> Co-authored-by: JonasKlotz <[email protected]>
1 parent 7bd8066 commit cdc1fee

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

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",

0 commit comments

Comments
 (0)