code: def collect_files(img_dir, gt_dir):
      suffix = "leftImg8bit.png"
      files = []
      for img_file in glob.glob(osp.join(img_dir, "**/*.png")):
          assert img_file.endswith(suffix), img_file
          inst_file = (
              gt_dir
              + img_file[len(img_dir) : -len(suffix)]
              + "gtFine_instanceIds.png"
          )
          # Note that labelIds are not converted to trainId for seg map
          segm_file = (
              gt_dir
              + img_file[len(img_dir) : -len(suffix)]
              + "gtFine_labelIds.png"
          )
          files.append((img_file, inst_file, segm_file))
      assert len(files), f"No images found in {img_dir}"
      print(f"Loaded {len(files)} images from {img_dir}")
  
      return files
  
file_path: mmdetection/tools/dataset_converters/cityscapes.py
imports: import argparse
  import glob
  import os.path
  import cityscapesscripts.helpers.labels
  import mmcv
  import numpy
  import pycocotools.mask
  from mmengine.fileio import dump
  from mmengine.utils import Timer, mkdir_or_exist, track_parallel_progress, track_progress
label_desc: Use image node_id 1 for calling a global function with example usage: collect_files(img_dir, gt_dir) and returns: files