Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
import os
import tarfile as tar
from pathlib import Path
from torchvision.datasets.utils import download_url
import numpy as np
import torch
import torchvision
#
#Downlaod cifar10 dataset
#
url = Path("http://files.fast.ai/data")
filename = "cifar10.tgz"
root = Path("./data")
download_url(url = url/filename, root = root)
Using downloaded and verified file: data/cifar10.tgz
#
#Unzip cifar10.tgz
#
with tar.open(name = root/filename, mode = 'r:gz') as cifar10:
cifar10.extractall(path = root)
cifar10_dir = root/"cifar10"
os.listdir(cifar10_dir)
['train', 'test', 'labels.txt']
#
#Cifar10 classes
#
os.listdir(cifar10_dir/"train")
['dog',
'deer',
'horse',
'cat',
'truck',
'airplane',
'automobile',
'ship',
'bird',
'frog']