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
10 changes: 7 additions & 3 deletions torchvision/datasets/caltech.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ def download(self) -> None:
download_and_extract_archive(
"http://www.vision.caltech.edu/Image_Datasets/Caltech101/101_ObjectCategories.tar.gz",
self.root,
filename="101_ObjectCategories.tar.gz",
md5="b224c7392d521a49829488ab0f1120d9",
)
download_and_extract_archive(
"http://www.vision.caltech.edu/Image_Datasets/Caltech101/Annotations.tar",
self.root,
filename="101_Annotations.tar",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For some (probably unintended) reason, we renamed this file instead of leaving it as is.

md5="6f83eeb1f24d99cab4eb377263132c91",
)

Expand Down Expand Up @@ -184,7 +182,13 @@ def __init__(
self.index: List[int] = []
self.y = []
for (i, c) in enumerate(self.categories):
n = len(os.listdir(os.path.join(self.root, "256_ObjectCategories", c)))
n = len(
[
item
for item in os.listdir(os.path.join(self.root, "256_ObjectCategories", c))
if item.endswith(".jpg")
]
)
Comment on lines +185 to +191
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The folders contain one rogue folder as well as one rogue file. Just going by the number of items in the folder and assuming everything is an image, will result in an error if we iterate over the complete dataset.

self.index.extend(range(1, n + 1))
self.y.extend(n * [i])

Expand Down