from pathlib import Path


def get_image_db(data_folder='data'):
    """Returns a mapping from test sets to ordered image filenames."""
    root = Path(data_folder)
    d = {}
    for test_set in root.glob('*.images'):
        img_names = []
        test_set_name = test_set.name.replace('.images', '')
        with open(test_set) as f:
            for line in f:
                img_names.append(test_set_name + '/' + line.strip())
        d[test_set_name] = img_names
    return d