How to read ImageNet dataset, val or test file?

I am getting a RuntimeError. Recently I downloaded the ImageNet dataset from Kaggle and it is a large zip file. I just want to evaluate a trained dataset, but I can’t read the eval file.

path = "/home/me/Desktop/IMGNetDataset/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/val"


batch_size = 128

workers = 0

transform = transforms.Compose([ transforms.Resize(256),
                                    transforms.CenterCrop(224),
                                    transforms.ToTensor(),
                                    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
                                  ])

preprocessing = dset.ImageNet(root=import_dataset,
                                                    transform = transform )
                                
test_sampler = SequentialSampler(preprocessing)


dataloader = DataLoader(preprocessing, batch_size=batch_size, sampler= test_sampler,
                               shuffle=False, num_workers=workers)




There is not such file ILSVRC2012_devkit_t12.tar.gz in the downloaded dataset.

RuntimeError: The archive ILSVRC2012_devkit_t12.tar.gz is not present in the root directory or is corrupted. You need to download it externally and place it in /home/me/Desktop/IMGNetDataset/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/.

I had a similar issue before. Anyways, The error message indicates that the file ILSVRC2012_devkit_t12.tar.gz is missing or corrupted. Try Downloading the file from the original source and place it in the proper directory.

Thanks, but now works only with the “train” file and doesn’t recognize any “val” file.


preprocessing = dset.ImageNet(root=datapath,
                                  split="val",
                                  transform= transform)


FileNotFoundError: Couldn't find any class folder in /home/me/Desktop/IMGNetDataset/imagenet-object-localization-challenge/ILSVRC/Data/CLS-LOC/val.

The file “val” contains ILSVRC2012_val_00000001.JPEG , I don’t know if is it in the right form. The train file contains subfolders

I checked the ImageNet dataset in google Colab. There is no problem. That file name is fine.
I used the links below to download “val”:

!wget https://image-net.org/data/ILSVRC/2012/ILSVRC2012_img_train.tar --no-check-certificate
and
!wget https://image-net.org/data/ILSVRC/2012/ILSVRC2012_img_val.tar --no-check-certificate

1 Like

Yes it works now, for train and val, what about test file? There is no option in PyTorch for splitting also the test file.