如何在PyTorch的transforms.Compose中使用自定義的Data Augmentation?

本文將以彩色Histogram Equalization為例,搭配OpenCV建立一個hisEqulColor的class,並與PyTorch的transforms.Compose結合,將Histogram Equalization效果應用到Dataset中

# OpenCV和Pillow格式互轉:# opencv -> pil
img_pil = Image.fromarray(cv2.cvtColor(img_cv,cv2.COLOR_BGR2RGB))
# pil -> opencv
img_cv = cv2.cvtColor(np.asarray(img_pil),cv2.COLOR_RGB2BGR)

解決PyTorch DataLoader中PIL TypeError: Cannot handle this data type問題 — Yanwei Liu — Medium

--

--

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