I have my own dataset. So, I want to build a CNN model based on my own dataset. I have to write a new Dataset function to substitute the official Dataset. But, I get an error and will post picture in the end. My question is how to read an image in the official Dataset? In my code, i use torchvision.io.read_img to read an image, but get error “TypeError: pic should be PIL Image or ndarray. Got <class ‘torch.Tensor’>”.
I have solved this problem, because I use trochvision.io.read_img to read IMG. So I get a Tensor, and think that transform.resize operate in Img. So i need to convert tensor to img. using transform.ToPILImage to do that.
Good job finding your own solution.
The transforms should also work on tensors these days.