I’m getting memory error for the below code which I expect.
import matplotlib.pyplot as plt
%matplotlib inline
# obtain one batch of training images
dataiter = iter(train_loader)
images, labels = dataiter.next()
images = images.numpy()
Is there any other way to resize rescale and then load the data using pytorch?I. e., Not read the data directly from the folder and resize rescale by code then use DataLoader ?
What kind of error do you get? Are you really running out of memory?
A single image in torch.uint8 would take approx 5100*3500*3/1024**2 = 51MB.
So even with a batch size of 4 and even if the next batch is already loaded using multiple workers, you’ll use less than 500MB.
Could you post the error message and the stack trace if possible?
Well, images are loaded in torchvision using PIL. So basically all formats are supported as long as you can use a library to load the data. rawpy seems to be able to handle raw image data.
You would need to create your own Dataset and write the code to read and process the images in __getitem__ or alternatively you could write a loader and pass it to torchvision.datasets.ImageFolder.