Skip to content

Commit c99aaa0

Browse files
committed
used the reccomended method for unzipping the files
1 parent 7607454 commit c99aaa0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

torchvision/datasets/caltech.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ def download(self) -> None:
138138
filename="caltech-101.zip",
139139
md5="3138e1922a9193bfa496528edbbc45d0",
140140
)
141-
extracted_dir = os.path.join(self.root, "caltech-101")
142-
extract_archive(os.path.join(extracted_dir, "101_ObjectCategories.tar.gz"), self.root)
143-
extract_archive(os.path.join(extracted_dir, "Annotations.tar.gz"), self.root) # Note: Annotations is now also .tar.gz in the new archive
144-
shutil.rmtree(extracted_dir)
141+
gzip_folder = os.path.join(self.root, "caltech-101")
142+
for gzip_file in os.listdir(gzip_folder):
143+
if gzip_file.endswith(".gz"):
144+
extract_archive(os.path.join(gzip_folder, gzip_file), self.root)
145+
shutil.rmtree(gzip_folder)
145146
os.remove(os.path.join(self.root, "caltech-101.zip"))
146147

147148

0 commit comments

Comments
 (0)