From 3665101d3a987fd983a1c6771777adea3c719c3c Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Tue, 24 Oct 2023 08:02:59 +0200 Subject: [PATCH] [config.data.nih_cxr14.datamodule] Fix loading of RGBA-encoded images (closes #51) --- src/ptbench/config/data/nih_cxr14/datamodule.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ptbench/config/data/nih_cxr14/datamodule.py b/src/ptbench/config/data/nih_cxr14/datamodule.py index 9875985f..69f044eb 100644 --- a/src/ptbench/config/data/nih_cxr14/datamodule.py +++ b/src/ptbench/config/data/nih_cxr14/datamodule.py @@ -89,8 +89,10 @@ class RawDataLoader(_BaseRawDataLoader): basename, ) - # N.B.: NIH CXR-14 images are encoded as color PNGs + # N.B.: some NIH CXR-14 images are encoded as color PNGs with an alpha + # channel. Most, are grayscale PNGs image = PIL.Image.open(os.path.join(self.datadir, file_path)) + image = image.convert("L") # required for some images tensor = to_tensor(image) # use the code below to view generated images -- GitLab