Learn practical skills, build real-world projects, and advance your career
import torch
import torchvision
import tarfile
from torchvision.datasets.utils import download_url
# extract from achive
#with tarfile.open('./cifar10.tgz', 'r:gz') as tar:
#    tar.extractall(path = './data')

The dataset has been extracted to the directory data/cifar10. It contains two folders - train and test, containing the training set(50000 images) and the test set(10000 images) respectively. Each of them contains 10 folders, one for each class of images. Let's verify this using os.listdir

import os
data_dir = './data/cifar10'

print(os.listdir(data_dir))
classes = os.listdir(data_dir + '/train')
print(classes)
['labels.txt', 'test', 'train'] ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']

Let's take a look inside a couple of folders, one from training set and one from test set.