Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for ImageNet #1149

Merged
merged 1 commit into from
Jul 22, 2019
Merged
Changes from all commits
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
7 changes: 3 additions & 4 deletions torchvision/datasets/imagenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ImageNet(ImageFolder):
loader (callable, optional): A function to load an image given its path.

Attributes:
classes (list): List of the class names.
classes (list): List of the class name tuples.
class_to_idx (dict): Dict with items (class_name, class_index).
wnids (list): List of the WordNet IDs.
wnid_to_idx (dict): Dict with items (wordnet_id, class_index).
Expand All @@ -57,12 +57,11 @@ def __init__(self, root, split='train', download=False, **kwargs):
super(ImageNet, self).__init__(self.split_folder, **kwargs)
self.root = root

idcs = [idx for _, idx in self.imgs]
self.wnids = self.classes
self.wnid_to_idx = {wnid: idx for idx, wnid in zip(idcs, self.wnids)}
self.wnid_to_idx = self.class_to_idx
self.classes = [wnid_to_classes[wnid] for wnid in self.wnids]
self.class_to_idx = {cls: idx
for clss, idx in zip(self.classes, idcs)
for idx, clss in enumerate(self.classes)
for cls in clss}

def download(self):
Expand Down