Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions torchvision/datasets/caltech.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we re-use the code from other datasets? For instance in "mnist.py" to extract all possible subdirectories?

for gzip_file in os.listdir(gzip_folder):
    if gzip_file.endswith(".gz"):
        extract_archive(os.path.join(gzip_folder, gzip_file), self.raw_folder)
    shutil.rmtree(gzip_folder)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that works as well.. I will change this one :)

os.remove(os.path.join(self.root, "caltech-101.zip"))



def extra_repr(self) -> str:
return "Target type: {target_type}".format(**self.__dict__)
Expand Down Expand Up @@ -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",
Expand Down
Loading