FileNotFoundError

Hello,

I am trying to reproduce the code implemented on

https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html

but i kept seeing this error FileNotFoundError.

The issue i believe is at the data loading stage. The original code loaded the data on dataroot = “data/celeba”. I am trying to do the same.

I created a folder celebrities_images inside which i saved the folder containing the training images named celeba and the python file is also saved in celebrities_images folder. I loading the data i used the command: dataroot = “/Celebrities_Image/celeba” but i kept getting FileNotFoundError: [Errno 2] No such file or directory: ‘/Celebrities_Image/celeba’

PS: I am working on Linux and Celebrities_Image folder in home directory

Regards,
Mohammad

Use dataroot = “./Celebrities_Image/celeba” or dataroot = “Celebrities_Image/celeba”

2 Likes

I am using the following code, but it showing the FileNotFoundError. I have tried several times, but could not run the code correctly. Can anyone please fix the error?

data_dir = ‘Cat_Dog_data/train’

transform = transforms.Compose([transforms.Resize((224,224)),
transforms.CenterCrop(224),
transforms.ToTensor()])
dataset = datasets.ImageFolder(data_dir, transform=transform)
dataloader = torch.utils.data.DataLoader(dataset, batch_size=32, shuffle=True)

Cat_Dog_data/train cannot be found on your system so you would have to verify that you are indeed in the right working directory and that the specified folder path really exists.