The simplest way would be to just write out the images to folder and use https://pytorch.org/docs/stable/torchvision/datasets.html#torchvision.datasets.ImageFolder 443
Also you got this error because your model is defined in 32 bit floating point but your data is probably in 64 bit floating point