def collect_files(img_dir, gt_dir):
    'Collect all images and their corresponding groundtruth files.\n\n    Args:\n        img_dir (str): The image directory\n        gt_dir (str): The groundtruth directory\n\n    Returns:\n        files (list): The list of tuples (img_file, groundtruth_file)\n    '
    assert isinstance(img_dir, str)
    assert img_dir
    assert isinstance(gt_dir, str)
    assert gt_dir
    (ann_list, imgs_list) = ([], [])
    for gt_file in os.listdir(gt_dir):
        ann_list.append(osp.join(gt_dir, gt_file))
        imgs_list.append(osp.join(img_dir, gt_file.replace('.json', '.png')))
    files = list(zip(sorted(imgs_list), sorted(ann_list)))
    assert len(files), f'No images found in {img_dir}'
    print(f'Loaded {len(files)} images from {img_dir}')
    return files
Collect all images and their corresponding groundtruth files.

Args:
    img_dir (str): The image directory
    gt_dir (str): The groundtruth directory

Returns:
    files (list): The list of tuples (img_file, groundtruth_file)
def collect_files(img_dir, gt_dir):
    'Collect all images and their corresponding groundtruth files.\n\n    Args:\n        img_dir (str): The image directory\n        gt_dir (str): The groundtruth directory\n\n    Returns:\n        files (list): The list of tuples (img_file, groundtruth_file)\n    '
    assert isinstance(img_dir, str)
    assert img_dir
    assert isinstance(gt_dir, str)
    assert gt_dir
    (ann_list, imgs_list) = ([], [])
    for gt_file in os.listdir(gt_dir):
        ann_list.append(osp.join(gt_dir, gt_file))
        imgs_list.append(osp.join(img_dir, gt_file.replace('.json', '.png')))
    files = list(zip(sorted(imgs_list), sorted(ann_list)))
    assert len(files), f'No images found in {img_dir}'
    print(f'Loaded {len(files)} images from {img_dir}')
    return files