def _process_dir(self, dir_path, json_path, relabel):
    if osp.exists(json_path):
        print('=> {} generated before, awesome!'.format(json_path))
        split = read_json(json_path)
        return split['tracklets']
    print('=> Automatically generating split (might take a while for the first time, have a coffe)')
    pdirs = glob.glob(osp.join(dir_path, '*'))
    print("Processing '{}' with {} person identities".format(dir_path, len(pdirs)))
    pid_container = set()
    for pdir in pdirs:
        pid = int(osp.basename(pdir))
        pid_container.add(pid)
    pid2label = {pid: label for (label, pid) in enumerate(pid_container)}
    tracklets = []
    for pdir in pdirs:
        pid = int(osp.basename(pdir))
        if relabel:
            pid = pid2label[pid]
        tdirs = glob.glob(osp.join(pdir, '*'))
        for tdir in tdirs:
            raw_img_paths = glob.glob(osp.join(tdir, '*.jpg'))
            num_imgs = len(raw_img_paths)
            if (num_imgs < self.min_seq_len):
                continue
            img_paths = []
            for img_idx in range(num_imgs):
                img_idx_name = ('F' + str((img_idx + 1)).zfill(4))
                res = glob.glob(osp.join(tdir, (('*' + img_idx_name) + '*.jpg')))
                if (len(res) == 0):
                    print('Warn: index name {} in {} is missing, jump to next'.format(img_idx_name, tdir))
                    continue
                img_paths.append(res[0])
            img_name = osp.basename(img_paths[0])
            if (img_name.find('_') == (- 1)):
                camid = (int(img_name[5]) - 1)
            else:
                camid = (int(img_name[6]) - 1)
            img_paths = tuple(img_paths)
            tracklets.append((img_paths, pid, camid))
    print('Saving split to {}'.format(json_path))
    split_dict = {'tracklets': tracklets}
    write_json(split_dict, json_path)
    return tracklets
def _process_dir(self, dir_path, json_path, relabel):
    if osp.exists(json_path):
        print('=> {} generated before, awesome!'.format(json_path))
        split = read_json(json_path)
        return split['tracklets']
    print('=> Automatically generating split (might take a while for the first time, have a coffe)')
    pdirs = glob.glob(osp.join(dir_path, '*'))
    print("Processing '{}' with {} person identities".format(dir_path, len(pdirs)))
    pid_container = set()
    for pdir in pdirs:
        pid = int(osp.basename(pdir))
        pid_container.add(pid)
    pid2label = {pid: label for (label, pid) in enumerate(pid_container)}
    tracklets = []
    for pdir in pdirs:
        pid = int(osp.basename(pdir))
        if relabel:
            pid = pid2label[pid]
        tdirs = glob.glob(osp.join(pdir, '*'))
        for tdir in tdirs:
            raw_img_paths = glob.glob(osp.join(tdir, '*.jpg'))
            num_imgs = len(raw_img_paths)
            if (num_imgs < self.min_seq_len):
                continue
            img_paths = []
            for img_idx in range(num_imgs):
                img_idx_name = ('F' + str((img_idx + 1)).zfill(4))
                res = glob.glob(osp.join(tdir, (('*' + img_idx_name) + '*.jpg')))
                if (len(res) == 0):
                    print('Warn: index name {} in {} is missing, jump to next'.format(img_idx_name, tdir))
                    continue
                img_paths.append(res[0])
            img_name = osp.basename(img_paths[0])
            if (img_name.find('_') == (- 1)):
                camid = (int(img_name[5]) - 1)
            else:
                camid = (int(img_name[6]) - 1)
            img_paths = tuple(img_paths)
            tracklets.append((img_paths, pid, camid))
    print('Saving split to {}'.format(json_path))
    split_dict = {'tracklets': tracklets}
    write_json(split_dict, json_path)
    return tracklets