def save_im_name_mapping(raw_dir, ori_to_new_im_name_file):
  im_names = []
  for dir_name in ['bounding_box_train', 'bounding_box_test', 'query']:
    im_names_ = get_im_names(osp.join(raw_dir, dir_name), return_path=False, return_np=False)
    im_names_.sort()
    # Images in different original directories may have same names,
    # so here we use relative paths as original image names.
    im_names_ = [osp.join(dir_name, n) for n in im_names_]
    im_names += im_names_
  new_im_names = map_im_names(im_names, parse_original_im_name, new_im_name_tmpl)
  ori_to_new_im_name = dict(zip(im_names, new_im_names))
  save_pickle(ori_to_new_im_name, ori_to_new_im_name_file)
  print('File saved to {}'.format(ori_to_new_im_name_file))

  ##################
  # Just Some Info #
  ##################

  print('len(im_names)', len(im_names))
  print('len(set(im_names))', len(set(im_names)))
  print('len(set(new_im_names))', len(set(new_im_names)))
  print('len(ori_to_new_im_name)', len(ori_to_new_im_name))

  bounding_box_train_im_names = get_im_names(osp.join(raw_dir, 'bounding_box_train'), return_path=False, return_np=False)
  bounding_box_test_im_names = get_im_names(osp.join(raw_dir, 'bounding_box_test'), return_path=False, return_np=False)
  query_im_names = get_im_names(osp.join(raw_dir, 'query'), return_path=False, return_np=False)

  print('set(bounding_box_train_im_names).isdisjoint(set(bounding_box_test_im_names))',
        set(bounding_box_train_im_names).isdisjoint(set(bounding_box_test_im_names)))
  print('set(bounding_box_train_im_names).isdisjoint(set(query_im_names))',
        set(bounding_box_train_im_names).isdisjoint(set(query_im_names)))

  print('set(bounding_box_test_im_names).isdisjoint(set(query_im_names))',
        set(bounding_box_test_im_names).isdisjoint(set(query_im_names)))
def save_im_name_mapping(raw_dir, ori_to_new_im_name_file):
  im_names = []
  for dir_name in ['bounding_box_train', 'bounding_box_test', 'query', 'gt_bbox']:
    im_names_ = get_im_names(osp.join(raw_dir, dir_name), return_path=False, return_np=False)
    im_names_.sort()
    # Filter out id -1
    if dir_name == 'bounding_box_test':
      im_names_ = [n for n in im_names_ if not n.startswith('-1')]
    # Get (id, cam) in query set
    if dir_name == 'query':
      q_ids_cams = set([(parse_original_im_name(n, 'id'), parse_original_im_name(n, 'cam')) for n in im_names_])
    # Filter out images that are not corresponding to query (id, cam)
    if dir_name == 'gt_bbox':
      im_names_ = [n for n in im_names_ if (parse_original_im_name(n, 'id'), parse_original_im_name(n, 'cam')) in q_ids_cams]
    # Images in different original directories may have same names,
    # so here we use relative paths as original image names.
    im_names_ = [osp.join(dir_name, n) for n in im_names_]
    im_names += im_names_
  new_im_names = map_im_names(im_names, parse_original_im_name, new_im_name_tmpl)
  ori_to_new_im_name = dict(zip(im_names, new_im_names))
  save_pickle(ori_to_new_im_name, ori_to_new_im_name_file)
  print('File saved to {}'.format(ori_to_new_im_name_file))

  ##################
  # Just Some Info #
  ##################

  print('len(im_names)', len(im_names))
  print('len(set(im_names))', len(set(im_names)))
  print('len(set(new_im_names))', len(set(new_im_names)))
  print('len(ori_to_new_im_name)', len(ori_to_new_im_name))

  bounding_box_train_im_names = get_im_names(osp.join(raw_dir, 'bounding_box_train'), return_path=False, return_np=False)
  bounding_box_test_im_names = get_im_names(osp.join(raw_dir, 'bounding_box_test'), return_path=False, return_np=False)
  query_im_names = get_im_names(osp.join(raw_dir, 'query'), return_path=False, return_np=False)
  gt_bbox_im_names = get_im_names(osp.join(raw_dir, 'gt_bbox'), return_path=False, return_np=False)

  print('set(bounding_box_train_im_names).isdisjoint(set(bounding_box_test_im_names))',
        set(bounding_box_train_im_names).isdisjoint(set(bounding_box_test_im_names)))
  print('set(bounding_box_train_im_names).isdisjoint(set(query_im_names))',
        set(bounding_box_train_im_names).isdisjoint(set(query_im_names)))
  print('set(bounding_box_train_im_names).isdisjoint(set(gt_bbox_im_names))',
        set(bounding_box_train_im_names).isdisjoint(set(gt_bbox_im_names)))

  print('set(bounding_box_test_im_names).isdisjoint(set(query_im_names))',
        set(bounding_box_test_im_names).isdisjoint(set(query_im_names)))
  print('set(bounding_box_test_im_names).isdisjoint(set(gt_bbox_im_names))',
        set(bounding_box_test_im_names).isdisjoint(set(gt_bbox_im_names)))

  print('set(query_im_names).isdisjoint(set(gt_bbox_im_names))',
        set(query_im_names).isdisjoint(set(gt_bbox_im_names)))

  print('len(query_im_names)', len(query_im_names))
  print('len(gt_bbox_im_names)', len(gt_bbox_im_names))
  print('len(set(query_im_names) & set(gt_bbox_im_names))', len(set(query_im_names) & set(gt_bbox_im_names)))
  print('len(set(query_im_names) | set(gt_bbox_im_names))', len(set(query_im_names) | set(gt_bbox_im_names)))
Example #3
0
def save_im_name_mapping(raw_dir, ori_to_new_im_name_file):
    im_names = []
    for dir_name in ['bounding_box_train', 'bounding_box_test', 'query']:
        im_names_ = get_im_names(osp.join(raw_dir, dir_name),
                                 return_path=False,
                                 return_np=False)
        im_names_.sort()
        # Images in different original directories may have same names,
        # so here we use relative paths as original image names.
        im_names_ = [osp.join(dir_name, n) for n in im_names_]
        im_names += im_names_
    new_im_names = map_im_names(im_names, parse_original_im_name,
                                new_im_name_tmpl)
    ori_to_new_im_name = dict(zip(im_names, new_im_names))
    save_pickle(ori_to_new_im_name, ori_to_new_im_name_file)
    print('File saved to {}'.format(ori_to_new_im_name_file))

    ##################
    # Just Some Info #
    ##################

    print('len(im_names)', len(im_names))
    print('len(set(im_names))', len(set(im_names)))
    print('len(set(new_im_names))', len(set(new_im_names)))
    print('len(ori_to_new_im_name)', len(ori_to_new_im_name))

    bounding_box_train_im_names = get_im_names(osp.join(
        raw_dir, 'bounding_box_train'),
                                               return_path=False,
                                               return_np=False)
    bounding_box_test_im_names = get_im_names(osp.join(raw_dir,
                                                       'bounding_box_test'),
                                              return_path=False,
                                              return_np=False)
    query_im_names = get_im_names(osp.join(raw_dir, 'query'),
                                  return_path=False,
                                  return_np=False)

    print(
        'set(bounding_box_train_im_names).isdisjoint(set(bounding_box_test_im_names))',
        set(bounding_box_train_im_names).isdisjoint(
            set(bounding_box_test_im_names)))
    print('set(bounding_box_train_im_names).isdisjoint(set(query_im_names))',
          set(bounding_box_train_im_names).isdisjoint(set(query_im_names)))

    print('set(bounding_box_test_im_names).isdisjoint(set(query_im_names))',
          set(bounding_box_test_im_names).isdisjoint(set(query_im_names)))
def save_images(zip_file, save_dir=None, train_test_split_file=None):
    """Rename and move all used images to a directory."""

    print("Extracting zip file")
    root = osp.dirname(osp.abspath(zip_file))
    if save_dir is None:
        save_dir = root
    may_make_dir(save_dir)
    with ZipFile(zip_file) as z:
        z.extractall(path=save_dir)
    print("Extracting zip file done")

    new_im_dir = osp.join(save_dir, 'images')
    may_make_dir(new_im_dir)
    raw_dir = osp.join(save_dir, osp.basename(zip_file)[:-4])

    im_paths = []
    nums = []

    for dir_name in ['bounding_box_train', 'bounding_box_test', 'query']:
        im_paths_ = get_im_names(osp.join(raw_dir, dir_name),
                                 return_path=True,
                                 return_np=False)
        im_paths_.sort()
        im_paths += list(im_paths_)
        nums.append(len(im_paths_))

    im_names = move_ims(im_paths, new_im_dir, parse_original_im_name,
                        new_im_name_tmpl)

    split = dict()
    keys = ['trainval_im_names', 'gallery_im_names', 'q_im_names']
    inds = [0] + nums
    inds = np.cumsum(inds)
    for i, k in enumerate(keys):
        split[k] = im_names[inds[i]:inds[i + 1]]

    save_pickle(split, train_test_split_file)
    print('Saving images done.')
    return split
def save_images(zip_file, save_dir=None, train_test_split_file=None):
  """Rename and move all used images to a directory."""

  print("Extracting zip file")
  root = osp.dirname(osp.abspath(zip_file))
  if save_dir is None:
    save_dir = root
  may_make_dir(save_dir)
  with ZipFile(zip_file) as z:
    z.extractall(path=save_dir)
  print("Extracting zip file done")

  new_im_dir = osp.join(save_dir, 'images')
  may_make_dir(new_im_dir)
  raw_dir = osp.join(save_dir, osp.basename(zip_file)[:-4])

  im_paths = []
  nums = []

  for dir_name in ['bounding_box_train', 'bounding_box_test', 'query']:
    im_paths_ = get_im_names(osp.join(raw_dir, dir_name),
                             return_path=True, return_np=False)
    im_paths_.sort()
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))

  im_names = move_ims(
    im_paths, new_im_dir, parse_original_im_name, new_im_name_tmpl)

  split = dict()
  keys = ['trainval_im_names', 'gallery_im_names', 'q_im_names']
  inds = [0] + nums
  inds = np.cumsum(inds)
  for i, k in enumerate(keys):
    split[k] = im_names[inds[i]:inds[i + 1]]

  save_pickle(split, train_test_split_file)
  print('Saving images done.')
  return split
def save_images(zip_file, save_dir=None, train_test_split_file=None):
    """Rename and move all used images to a directory."""

    print("Extracting zip file")
    root = osp.dirname(osp.abspath(zip_file))
    if save_dir is None:
        save_dir = root
    may_make_dir(osp.abspath(save_dir))
    with ZipFile(zip_file) as z:
        z.extractall(path=save_dir)
    print("Extracting zip file done")

    new_im_dir = osp.join(save_dir, 'images')
    may_make_dir(osp.abspath(new_im_dir))
    raw_dir = osp.join(save_dir, osp.basename(zip_file)[:-4])

    im_paths = []
    nums = []

    im_paths_ = get_im_names(osp.join(raw_dir, 'bounding_box_train'),
                             return_path=True,
                             return_np=False)
    im_paths_.sort()
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))

    im_paths_ = get_im_names(osp.join(raw_dir, 'bounding_box_test'),
                             return_path=True,
                             return_np=False)
    im_paths_.sort()
    im_paths_ = [p for p in im_paths_ if not osp.basename(p).startswith('-1')]
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))

    im_paths_ = get_im_names(osp.join(raw_dir, 'query'),
                             return_path=True,
                             return_np=False)
    im_paths_.sort()
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))
    q_ids_cams = set([(parse_original_im_name(osp.basename(p), 'id'),
                       parse_original_im_name(osp.basename(p), 'cam'))
                      for p in im_paths_])

    im_paths_ = get_im_names(osp.join(raw_dir, 'gt_bbox'),
                             return_path=True,
                             return_np=False)
    im_paths_.sort()
    # Only gather images for those ids and cams used in testing.
    im_paths_ = [
        p for p in im_paths_
        if (parse_original_im_name(osp.basename(p), 'id'),
            parse_original_im_name(osp.basename(p), 'cam')) in q_ids_cams
    ]
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))

    im_names = move_ims(im_paths, new_im_dir, parse_original_im_name,
                        new_im_name_tmpl)

    split = dict()
    keys = [
        'trainval_im_names', 'gallery_im_names', 'q_im_names', 'mq_im_names'
    ]
    inds = [0] + nums
    inds = np.cumsum(np.array(inds))
    for i, k in enumerate(keys):
        split[k] = im_names[inds[i]:inds[i + 1]]

    save_pickle(split, train_test_split_file)
    print('Saving images done.')
    return split
def save_images(original_file, save_dir=None, train_test_split_file=None):
    """Rename and move all used images to a directory."""

    # print("Extracting zip file")
    root = osp.dirname(osp.abspath(original_file))
    if save_dir is None:
        save_dir = root
    may_make_dir(osp.abspath(save_dir))
    # with ZipFile(original_file) as z:
    #   z.extractall(path=save_dir)
    # print("Extracting zip file done")

    new_im_dir = osp.join(save_dir, 'images')
    may_make_dir(osp.abspath(new_im_dir))
    raw_dir = osp.abspath(original_file)
    print('raw_dir: ', raw_dir)

    im_paths = []
    nums = []

    im_paths_ = get_im_names(osp.join(raw_dir, 'bounding_box_train'),
                             pattern='*.png',
                             return_path=True,
                             return_np=False)
    im_paths_.sort()
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))
    print('dir_name:   bounding_box_train')
    print('nums:   ', nums)

    # Create (anchor, positive, negative)
    anchor_positive_negative_2(im_paths, parse_original_im_name, save_dir)

    im_paths_ = get_im_names(osp.join(raw_dir, 'bounding_box_test'),
                             pattern='*.png',
                             return_path=True,
                             return_np=False)
    im_paths_.sort()
    im_paths_ = [p for p in im_paths_ if not osp.basename(p).startswith('-1')]
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))
    print('dir_name:   bounding_box_test')
    print('nums:   ', nums)

    im_paths_ = get_im_names(osp.join(raw_dir, 'query'),
                             pattern='*.png',
                             return_path=True,
                             return_np=False)
    im_paths_.sort()
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))
    q_ids_cams = set([(parse_original_im_name(osp.basename(p), 'id'),
                       parse_original_im_name(osp.basename(p), 'cam'))
                      for p in im_paths_])
    print('dir_name:   query')
    print('nums:   ', nums)

    im_paths_ = get_im_names(osp.join(raw_dir, 'gt_bbox'),
                             pattern='*.png',
                             return_path=True,
                             return_np=False)
    im_paths_.sort()
    #print('len of im_paths:'+str(len(im_paths)))
    # Only gather images for those ids and cams used in testing.
    im_paths_ = [
        p for p in im_paths_
        if (parse_original_im_name(osp.basename(p), 'id'),
            parse_original_im_name(osp.basename(p), 'cam')) in q_ids_cams
    ]
    im_paths += list(im_paths_)
    nums.append(len(im_paths_))
    print('dir_name:   gt_bbox')
    print('nums:   ', nums)

    im_names = move_ims_2(im_paths, parse_original_im_name, new_im_name_tmpl)

    split = dict()
    keys = [
        'trainval_im_names', 'gallery_im_names', 'q_im_names', 'mq_im_names'
    ]
    inds = [0] + nums
    print('inds:   ', inds)
    inds = np.cumsum(np.array(inds))
    print('inds:   ', inds)
    print('enumerate(keys):   ', enumerate(keys))
    for i, k in enumerate(keys):
        print('i,k: ', i, k)
        split[k] = im_names[inds[i]:inds[i + 1]]

    save_pickle(split, train_test_split_file)
    print('Saving images done.')

    return split
def save_images(zip_file, save_dir=None, train_test_split_file=None):
  """Rename and move all used images to a directory."""

  print("Extracting zip file")
  root = osp.dirname(osp.abspath(zip_file))
  if save_dir is None:
    save_dir = root
  may_make_dir(osp.abspath(save_dir))
  with ZipFile(zip_file) as z:
    z.extractall(path=save_dir)
  print("Extracting zip file done")

  new_im_dir = osp.join(save_dir, 'images')
  may_make_dir(osp.abspath(new_im_dir))
  raw_dir = osp.join(save_dir, osp.basename(zip_file)[:-4])

  im_paths = []
  nums = []

  im_paths_ = get_im_names(osp.join(raw_dir, 'bounding_box_train'),
                           return_path=True, return_np=False)
  im_paths_.sort()
  im_paths += list(im_paths_)
  nums.append(len(im_paths_))

  im_paths_ = get_im_names(osp.join(raw_dir, 'bounding_box_test'),
                           return_path=True, return_np=False)
  im_paths_.sort()
  im_paths_ = [p for p in im_paths_ if not osp.basename(p).startswith('-1')]
  im_paths += list(im_paths_)
  nums.append(len(im_paths_))

  im_paths_ = get_im_names(osp.join(raw_dir, 'query'),
                           return_path=True, return_np=False)
  im_paths_.sort()
  im_paths += list(im_paths_)
  nums.append(len(im_paths_))
  q_ids_cams = set([(parse_original_im_name(osp.basename(p), 'id'),
                     parse_original_im_name(osp.basename(p), 'cam'))
                    for p in im_paths_])

  im_paths_ = get_im_names(osp.join(raw_dir, 'gt_bbox'),
                           return_path=True, return_np=False)
  im_paths_.sort()
  # Only gather images for those ids and cams used in testing.
  im_paths_ = [p for p in im_paths_
               if (parse_original_im_name(osp.basename(p), 'id'),
                   parse_original_im_name(osp.basename(p), 'cam'))
               in q_ids_cams]
  im_paths += list(im_paths_)
  nums.append(len(im_paths_))

  im_names = move_ims(
    im_paths, new_im_dir, parse_original_im_name, new_im_name_tmpl)

  split = dict()
  keys = ['trainval_im_names', 'gallery_im_names', 'q_im_names', 'mq_im_names']
  inds = [0] + nums
  inds = np.cumsum(np.array(inds))
  for i, k in enumerate(keys):
    split[k] = im_names[inds[i]:inds[i + 1]]

  save_pickle(split, train_test_split_file)
  print('Saving images done.')
  return split
Example #9
0
def save_im_name_mapping(raw_dir, ori_to_new_im_name_file):
    im_names = []
    for dir_name in [
            'bounding_box_train', 'bounding_box_test', 'query', 'gt_bbox'
    ]:
        im_names_ = get_im_names(osp.join(raw_dir, dir_name),
                                 return_path=False,
                                 return_np=False)
        im_names_.sort()
        # Filter out id -1
        if dir_name == 'bounding_box_test':
            im_names_ = [n for n in im_names_ if not n.startswith('-1')]
        # Get (id, cam) in query set
        if dir_name == 'query':
            q_ids_cams = set([(parse_original_im_name(n, 'id'),
                               parse_original_im_name(n, 'cam'))
                              for n in im_names_])
        # Filter out images that are not corresponding to query (id, cam)
        if dir_name == 'gt_bbox':
            im_names_ = [
                n for n in im_names_
                if (parse_original_im_name(n, 'id'),
                    parse_original_im_name(n, 'cam')) in q_ids_cams
            ]
        # Images in different original directories may have same names,
        # so here we use relative paths as original image names.
        im_names_ = [osp.join(dir_name, n) for n in im_names_]
        im_names += im_names_
    new_im_names = map_im_names(im_names, parse_original_im_name,
                                new_im_name_tmpl)
    ori_to_new_im_name = dict(zip(im_names, new_im_names))
    save_pickle(ori_to_new_im_name, ori_to_new_im_name_file)
    print('File saved to {}'.format(ori_to_new_im_name_file))

    ##################
    # Just Some Info #
    ##################

    print('len(im_names)', len(im_names))
    print('len(set(im_names))', len(set(im_names)))
    print('len(set(new_im_names))', len(set(new_im_names)))
    print('len(ori_to_new_im_name)', len(ori_to_new_im_name))

    bounding_box_train_im_names = get_im_names(osp.join(
        raw_dir, 'bounding_box_train'),
                                               return_path=False,
                                               return_np=False)
    bounding_box_test_im_names = get_im_names(osp.join(raw_dir,
                                                       'bounding_box_test'),
                                              return_path=False,
                                              return_np=False)
    query_im_names = get_im_names(osp.join(raw_dir, 'query'),
                                  return_path=False,
                                  return_np=False)
    gt_bbox_im_names = get_im_names(osp.join(raw_dir, 'gt_bbox'),
                                    return_path=False,
                                    return_np=False)

    print(
        'set(bounding_box_train_im_names).isdisjoint(set(bounding_box_test_im_names))',
        set(bounding_box_train_im_names).isdisjoint(
            set(bounding_box_test_im_names)))
    print('set(bounding_box_train_im_names).isdisjoint(set(query_im_names))',
          set(bounding_box_train_im_names).isdisjoint(set(query_im_names)))
    print('set(bounding_box_train_im_names).isdisjoint(set(gt_bbox_im_names))',
          set(bounding_box_train_im_names).isdisjoint(set(gt_bbox_im_names)))

    print('set(bounding_box_test_im_names).isdisjoint(set(query_im_names))',
          set(bounding_box_test_im_names).isdisjoint(set(query_im_names)))
    print('set(bounding_box_test_im_names).isdisjoint(set(gt_bbox_im_names))',
          set(bounding_box_test_im_names).isdisjoint(set(gt_bbox_im_names)))

    print('set(query_im_names).isdisjoint(set(gt_bbox_im_names))',
          set(query_im_names).isdisjoint(set(gt_bbox_im_names)))

    print('len(query_im_names)', len(query_im_names))
    print('len(gt_bbox_im_names)', len(gt_bbox_im_names))
    print('len(set(query_im_names) & set(gt_bbox_im_names))',
          len(set(query_im_names) & set(gt_bbox_im_names)))
    print('len(set(query_im_names) | set(gt_bbox_im_names))',
          len(set(query_im_names) | set(gt_bbox_im_names)))
def save_images(data_dir, save_dir=None, train_test_split_file=None):
    """Rename and move all used images to a directory."""

    # print("Extracting zip file")
    # root = osp.dirname(osp.abspath(zip_file))
    # if save_dir is None:
    #   save_dir = root
    # may_make_dir(osp.abspath(save_dir))
    # with ZipFile(zip_file) as z:
    #   z.extractall(path=save_dir)
    # print("Extracting zip file done")
    #get the images and origin name of path
    new_im_dir = osp.join(save_dir, 'images')
    may_make_dir(osp.abspath(new_im_dir))
    # define paths of all images and number of files in four folders
    im_paths = []
    bb_test = []
    bb_test_num = 0
    bb_train_num = 0
    bb_train = []
    query = []
    query_num = 0
    gt_bb_num = 0
    gt_bb = []
    nums = []

    for data in dataset:
        raw_dir = osp.join(data_dir, data)
        im_paths_ = get_im_names(osp.join(raw_dir, 'bounding_box_train'),
                                 return_path=True,
                                 return_np=False)
        im_paths_.sort()
        bb_train += list(im_paths_)
        bb_train_num += len(im_paths_)

        im_paths_ = get_im_names(osp.join(raw_dir, 'bounding_box_test'),
                                 return_path=True,
                                 return_np=False)
        im_paths_.sort()
        im_paths_ = [
            p for p in im_paths_ if not osp.basename(p).startswith('-1')
        ]
        bb_test += list(im_paths_)
        bb_test_num += len(im_paths_)

        im_paths_ = get_im_names(osp.join(raw_dir, 'query'),
                                 return_path=True,
                                 return_np=False)
        im_paths_.sort()
        query += list(im_paths_)
        query_num += len(im_paths_)
        q_ids_cams = set([(parse_original_im_name(osp.basename(p), 'id'),
                           parse_original_im_name(osp.basename(p), 'cam'))
                          for p in im_paths_])

        im_paths_ = get_im_names(osp.join(raw_dir, 'gt_bbox'),
                                 return_path=True,
                                 return_np=False)
        im_paths_.sort()
        # Only gather images for those ids and cams used in testing.
        im_paths_ = [
            p for p in im_paths_
            if (parse_original_im_name(osp.basename(p), 'id'),
                parse_original_im_name(osp.basename(p), 'cam')) in q_ids_cams
        ]
        gt_bb += list(im_paths_)
        gt_bb_num += len(im_paths_)

    im_paths = bb_train + bb_test + query + gt_bb
    nums = [bb_train_num] + [bb_test_num] + [query_num] + [gt_bb_num]

    im_names = move_ims(im_paths, new_im_dir, parse_original_im_name,
                        new_im_name_tmpl)

    split = dict()
    keys = [
        'trainval_im_names', 'gallery_im_names', 'q_im_names', 'mq_im_names'
    ]
    inds = [0] + nums
    inds = np.cumsum(np.array(inds))
    for i, k in enumerate(keys):
        split[k] = im_names[inds[i]:inds[i + 1]]

    save_pickle(split, train_test_split_file)
    print('Saving images done.')
    return split