ESPCN-PyTorch icon indicating copy to clipboard operation
ESPCN-PyTorch copied to clipboard

Issue with TestDataLoader

Open urbste opened this issue 1 year ago • 0 comments

Hi,

I have an issue regarding the TestImageDataset. I do get an error running the training script, because the TestImageDataset actually does not load the right pair of images.

The paths to all images are loaded in this line. However the resulting list is not sorted according to the filenames. So it might happen that bird.png and baby.png are paired together, resulting in shape mismatch errors.

self.gt_image_file_names = [os.path.join(test_gt_images_dir, x) for x in os.listdir(test_gt_images_dir)]
self.lr_image_file_names = [os.path.join(test_lr_images_dir, x) for x in os.listdir(test_lr_images_dir)]

It can be solved by sorting the lists with the natsort package:

self.gt_image_file_names = natsort.natsorted([os.path.join(test_gt_images_dir, x) for x in os.listdir(test_gt_images_dir)])
self.lr_image_file_names = natsort.natsorted([os.path.join(test_lr_images_dir, x) for x in os.listdir(test_lr_images_dir)])

This should be fixed in any case, as it also might result in wrong test statistics.

Steffen

urbste avatar Jul 24 '23 12:07 urbste