From 76074546a49ea9cf9b8ec65670c4f1c29f02990a Mon Sep 17 00:00:00 2001 From: hrsvrn Date: Fri, 5 Sep 2025 01:02:45 +0530 Subject: [PATCH 1/3] Fixed Caltech-101 and Caltech-256 broken links with the official ones --- torchvision/datasets/caltech.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/torchvision/datasets/caltech.py b/torchvision/datasets/caltech.py index adcb49ff1c2..835176d8be9 100644 --- a/torchvision/datasets/caltech.py +++ b/torchvision/datasets/caltech.py @@ -2,10 +2,10 @@ import os.path from pathlib import Path from typing import Any, Callable, Optional, Union - +import shutil from PIL import Image -from .utils import download_and_extract_archive, verify_str_arg +from .utils import download_and_extract_archive, verify_str_arg,extract_archive from .vision import VisionDataset @@ -133,17 +133,18 @@ def download(self) -> None: return download_and_extract_archive( - "https://drive.google.com/file/d/137RyRjvTBkBiIfeYBNZBtViDHQ6_Ewsp", - self.root, - filename="101_ObjectCategories.tar.gz", - md5="b224c7392d521a49829488ab0f1120d9", - ) - download_and_extract_archive( - "https://drive.google.com/file/d/175kQy3UsZ0wUEHZjqkUDdNVssr7bgh_m", - self.root, - filename="Annotations.tar", - md5="6f83eeb1f24d99cab4eb377263132c91", + "https://data.caltech.edu/records/mzrjq-6wc02/files/caltech-101.zip", + download_root=self.root, + filename="caltech-101.zip", + md5="3138e1922a9193bfa496528edbbc45d0", ) + extracted_dir = os.path.join(self.root, "caltech-101") + extract_archive(os.path.join(extracted_dir, "101_ObjectCategories.tar.gz"), self.root) + extract_archive(os.path.join(extracted_dir, "Annotations.tar.gz"), self.root) # Note: Annotations is now also .tar.gz in the new archive + shutil.rmtree(extracted_dir) + os.remove(os.path.join(self.root, "caltech-101.zip")) + + def extra_repr(self) -> str: return "Target type: {target_type}".format(**self.__dict__) @@ -233,7 +234,7 @@ def download(self) -> None: return download_and_extract_archive( - "https://drive.google.com/file/d/1r6o0pSROcV1_VwT4oSjA2FBUSCWGuxLK", + "https://data.caltech.edu/records/nyy15-4j048/files/256_ObjectCategories.tar", self.root, filename="256_ObjectCategories.tar", md5="67b4f42ca05d46448c6bb8ecd2220f6d", From c99aaa00a92e9029828d0d1748559db54456af5b Mon Sep 17 00:00:00 2001 From: hrsvrn Date: Fri, 5 Sep 2025 19:38:58 +0530 Subject: [PATCH 2/3] used the reccomended method for unzipping the files --- torchvision/datasets/caltech.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/torchvision/datasets/caltech.py b/torchvision/datasets/caltech.py index 835176d8be9..19918b7cdf3 100644 --- a/torchvision/datasets/caltech.py +++ b/torchvision/datasets/caltech.py @@ -138,10 +138,11 @@ def download(self) -> None: filename="caltech-101.zip", md5="3138e1922a9193bfa496528edbbc45d0", ) - extracted_dir = os.path.join(self.root, "caltech-101") - extract_archive(os.path.join(extracted_dir, "101_ObjectCategories.tar.gz"), self.root) - extract_archive(os.path.join(extracted_dir, "Annotations.tar.gz"), self.root) # Note: Annotations is now also .tar.gz in the new archive - shutil.rmtree(extracted_dir) + gzip_folder = os.path.join(self.root, "caltech-101") + for gzip_file in os.listdir(gzip_folder): + if gzip_file.endswith(".gz"): + extract_archive(os.path.join(gzip_folder, gzip_file), self.root) + shutil.rmtree(gzip_folder) os.remove(os.path.join(self.root, "caltech-101.zip")) From 3bb37f46bc89a70af619082c0c4b608434f33271 Mon Sep 17 00:00:00 2001 From: Antoine Simoulin Date: Mon, 8 Sep 2025 14:47:15 -0700 Subject: [PATCH 3/3] lint --- torchvision/datasets/caltech.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/torchvision/datasets/caltech.py b/torchvision/datasets/caltech.py index 19918b7cdf3..7498f674001 100644 --- a/torchvision/datasets/caltech.py +++ b/torchvision/datasets/caltech.py @@ -1,11 +1,12 @@ import os import os.path +import shutil from pathlib import Path from typing import Any, Callable, Optional, Union -import shutil + from PIL import Image -from .utils import download_and_extract_archive, verify_str_arg,extract_archive +from .utils import download_and_extract_archive, extract_archive, verify_str_arg from .vision import VisionDataset @@ -144,8 +145,6 @@ def download(self) -> None: extract_archive(os.path.join(gzip_folder, gzip_file), self.root) shutil.rmtree(gzip_folder) os.remove(os.path.join(self.root, "caltech-101.zip")) - - def extra_repr(self) -> str: return "Target type: {target_type}".format(**self.__dict__)