How to load ImageNet

When I load the ImageNet I get the wrong classes… Either class 0 or class 1. But ImageNet should have 1000 classes. What am I doing wrong?

When I change to shuffle to true then I can see a lot different classes…

import os, sys, pdb
import argparse
import torch
import torch.nn as nn
import torchvision.datasets as datasets
import as data
import torchvision.transforms as transforms
import torchvision.models as models

if __name__ == '__main__'
    model = models.resnet18(pretrained=True)

    # load data
    transform_list = [transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor()]
    transform_chain = transforms.Compose(transform_list)
    data_dir = 'path/to/ImageNet'

    item = datasets.ImageFolder(data_dir + '/val', transform=transform_chain)

    test_loader = data.DataLoader(item, batch_size=100, shuffle=False, num_workers=4)

    inputs, classes = next(iter(test_loader))
    print("classes: ", classes)

The validation set for ImageNet has 50,000 images or 50 per each of the 1,000 classes. If you don’t shuffle the data then the expectation indeed is that you only see two classes for a batch size of 100.