BasicSR icon indicating copy to clipboard operation
BasicSR copied to clipboard

using a set for paired image verification

Open tiruns opened this issue 3 years ago • 0 comments

When reading images from a folder, the dataloader checks if the corresponding LR input exists. https://github.com/XPixelGroup/BasicSR/blob/db589b485b6ac5a1cfc47c0961dcf52ba1fb369a/basicsr/data/data_util.py#L228

However, the existing code uses a list for lookup, which could be slow when the number of images is large. https://github.com/XPixelGroup/BasicSR/blob/db589b485b6ac5a1cfc47c0961dcf52ba1fb369a/basicsr/data/data_util.py#L219

Using a set instead of a list may help solve this problem.

    input_paths = list(scandir(input_folder))
    input_paths_set = set(input_paths)
    # ...
    for gt_path in gt_paths:
        # ...
        assert input_name in input_paths_set, f'{input_name} is not in {input_key}_paths.'

tiruns avatar Jul 14 '22 07:07 tiruns