Load EMNIST dataset from within the Pytorch

164 Views Asked by At

I'm working on EMNIST dataset and want to load it from PyTorch, but it returns a strange error as:

RuntimeError: File not found or corrupted.

Here's how i have tried to load the dataset:

trainset = torchvision.datasets.EMNIST(root="emnist",
                                   split="letters",
                                   train=True,
                                   download=True,
                                   transform=transforms.ToTensor())

What might be wrong?

1

There are 1 best solutions below

0
DataSciRookie On

I think the link is incorrect, try to download the dataset with that :

https://github.com/Tony-Y/pytorch_warmup/blob/master/examples/emnist/download.py

And then change your code with :

import torchvision
from torchvision import transforms

# Update the path to where you've manually placed the EMNIST dataset
root_dir = "./path/to/your/emnist"  # Change this to the actual path

trainset = torchvision.datasets.EMNIST(root=root_dir,
                                   split="letters",
                                   train=True,
                                   download=False,  # Set to False since you already downloaded it 
                                   transform=transforms.ToTensor())