How to use MNIST dataset?


(oasjd7) #1

I have Office-31 amazon datasets like this.

amazon/images/bike/bike jpgs here...
             /keyboard/keyboard jpgs here...
             /trash_can/trash_can jpgs here...
              ...

I can use these data with

data_transforms = {
    transforms.Compose([
        transforms.RandomResizedCrop(224),
        transforms.RandomHorizontalFlip(),
        transforms.ToTensor(),
        transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
    ])
}

dsets = datasets.ImageFolder(root=data_dir + source_set + '/images', transform=data_transforms)
dset_loaders = {x: torch.utils.data.DataLoader(dsets, batch_size=int(BATCH_SIZE / 2), shuffle=True)
...

and now I want to use MNIST dataset in pytorch.
I know how to load MNIST using datasets.MNIST and DataLoader
but I don’t know how to load in this way. because I don’t have jpg files like amazon data.
Is there any way to download MNIST in jpgs with different folder name according to the class?
How can I load MNIST like amazon dataset?


(Max) #2

fast.ai provides MNIST as .png files, maybe this helps?