I am using pytorch to build a neural network classifier.
I read somewhere that many python packages use the same c++ api when reading a picture, so I thought skimage.io.imread and cv2.imread would be the same except channel order. However I got warning like this in skimage,
/xxx/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:766: UserWarning: Possibly corrupt EXIF data. Expecting to read 1245184 bytes but only got 0. Skipping tag 0
" Skipping tag %s" % (size, len(data), tag)
/xxx/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:785: UserWarning: Corrupt EXIF data. Expecting to read 12 bytes but only got 11.
warnings.warn(str(msg))
but cv2 works without warnings.
My code goes like this:
- in Dataset
...
def __getitem__(self, index):
file = os.path.join(self.root_dir, self.files[index])
image = io.imread(file)
# image = cv2.imread(file)
if self.transform:
image = self.transform(image)
return image
- transforms:
transform = transforms.Compose([
transforms.ToPILImage(),
transforms.Resize((128, 128)),
transforms.RandomHorizontalFlip(),
transforms.ToTensor()
])