解決PyTorch DataLoader中PIL TypeError: Cannot handle this data type問題

class WhiteBalance(object):
def __call__(self, img):
wbModel = wb_srgb.WBsRGB(gamut_mapping=2, upgraded=0)
img = cv2.cvtColor(np.asarray(img), cv2.COLOR_RGB2BGR)
img = wbModel.correctImage(img)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = (img * 255).round().astype(np.uint8)
return Image.fromarray(img)
def __repr__(self):
return self.__class__.__name__+'()'
transform_test = transforms.Compose([WhiteBalance(),
transforms.Resize([224, 224]),
transforms.ToTensor(),
normalize
])

參考資料

相關文章

--

--

Machine Learning | Deep Learning | https://linktr.ee/yanwei

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store