torchreid/data/datasets/image/deepinsight.py
def prepare_split(self):
        """
        Image name format: 0001001.png, where first four digits represent identity
        and last four digits represent cameras. Camera 1&2 are considered the same
        view and camera 3&4 are considered the same view.
        """
        if not osp.exists(self.split_path):
            print('Creating 10 random splits of train ids and test ids')
            img_paths = sorted(glob.glob(osp.join(self.dataset_dir, '*.jpg')))
            img_list = []
            pid_container = set()
            camid_container = set()
            for img_path in img_paths:
                img_name = osp.basename(img_path)
                pid, camid, datetime, sn = img_name.split('-')
                camid = int(camid)
                if '_' in pid:
                    pid, vid = pid.split('_')
                    pid = int(pid) - 1
                    img_list.append((img_path, pid, vid, camid))
                else:
                    pid = int(pid) - 1
                    img_list.append((img_path, pid, camid))
                pid_container.add(pid)
                camid_container.add(camid)

            num_pids = len(pid_container)
            num_train_pids, num_train_camids = num_pids // 2, len(camid_container) // 2

            splits = []
            for _ in range(10):
                # Shuffle the pids
                order = np.arange(num_pids)
                np.random.shuffle(order)
                train_idxs = np.sort(order[:num_train_pids])
                idx2label = {idx: label for label, idx in enumerate(train_idxs)}

                # Shuffle the camids
                order = np.array(list(camid_container))
                np.random.shuffle(order)
                cam_a_ids = np.sort(order[:num_train_camids])

                train, test_a, test_b = [], [], []
                for attr in img_list:  # (img_path, pid, (vid), camid)
                    if attr[1] in train_idxs:
                        attr = list(attr)
                        attr[1] = idx2label[attr[1]]
                        train.append(tuple(attr))
                    else:
                        if attr[-1] in cam_a_ids:
                            test_a.append(attr)
                        else:
                            test_b.append(attr)

                # use cameraA as query and cameraB as gallery
                split = {
                    'train': train,
                    'query': test_a,
                    'gallery': test_b,
                    'num_train_pids': num_train_pids,
                    'num_query_pids': num_pids - num_train_pids,
                    'num_gallery_pids': num_pids - num_train_pids
                }
                splits.append(split)

                # use cameraB as query and cameraA as gallery
                split = {
                    'train': train,
                    'query': test_b,
                    'gallery': test_a,
                    'num_train_pids': num_train_pids,
                    'num_query_pids': num_pids - num_train_pids,
                    'num_gallery_pids': num_pids - num_train_pids
                }
                splits.append(split)

            print('Totally {} splits are created'.format(len(splits)))
            write_json(splits, self.split_path)
            print('Split file saved to {}'.format(self.split_path))

        Image name format: 0001001.png, where first four digits represent identity
        and last four digits represent cameras. Camera 1&2 are considered the same
        view and camera 3&4 are considered the same view.
        
Image name format: 0001001.png, where first four digits represent identity
and last four digits represent cameras. Camera 1&2 are considered the same
view and camera 3&4 are considered the same view.
Image name format : 0001001 . png where first four digits represent identity and last four digits represent cameras . Camera 1&2 are considered the same view and camera 3&4 are considered the same view .
def prepare_split(self):
        if not osp.exists(self.split_path):
            print('Creating 10 random splits of train ids and test ids')
            img_paths = sorted(glob.glob(osp.join(self.dataset_dir, '*.jpg')))
            img_list = []
            pid_container = set()
            camid_container = set()
            for img_path in img_paths:
                img_name = osp.basename(img_path)
                pid, camid, datetime, sn = img_name.split('-')
                camid = int(camid)
                if '_' in pid:
                    pid, vid = pid.split('_')
                    pid = int(pid) - 1
                    img_list.append((img_path, pid, vid, camid))
                else:
                    pid = int(pid) - 1
                    img_list.append((img_path, pid, camid))
                pid_container.add(pid)
                camid_container.add(camid)
            num_pids = len(pid_container)
            num_train_pids, num_train_camids = num_pids // 2, len(camid_container) // 2
            splits = []
            for _ in range(10):
                order = np.arange(num_pids)
                np.random.shuffle(order)
                train_idxs = np.sort(order[:num_train_pids])
                idx2label = {idx: label for label, idx in enumerate(train_idxs)}
                order = np.array(list(camid_container))
                np.random.shuffle(order)
                cam_a_ids = np.sort(order[:num_train_camids])
                train, test_a, test_b = [], [], []
                for attr in img_list:  
                    if attr[1] in train_idxs:
                        attr = list(attr)
                        attr[1] = idx2label[attr[1]]
                        train.append(tuple(attr))
                    else:
                        if attr[-1] in cam_a_ids:
                            test_a.append(attr)
                        else:
                            test_b.append(attr)
                split = {
                    'train': train,
                    'query': test_a,
                    'gallery': test_b,
                    'num_train_pids': num_train_pids,
                    'num_query_pids': num_pids - num_train_pids,
                    'num_gallery_pids': num_pids - num_train_pids
                }
                splits.append(split)
                split = {
                    'train': train,
                    'query': test_b,
                    'gallery': test_a,
                    'num_train_pids': num_train_pids,
                    'num_query_pids': num_pids - num_train_pids,
                    'num_gallery_pids': num_pids - num_train_pids
                }
                splits.append(split)
            print('Totally {} splits are created'.format(len(splits)))
            write_json(splits, self.split_path)
            print('Split file saved to {}'.format(self.split_path))
def prepare_split ( self ) : if not osp . exists ( self . split_path ) : print ( 'Creating 10 random splits of train ids and test ids' ) img_paths = sorted ( glob . glob ( osp . join ( self . dataset_dir , '*.jpg' ) ) ) img_list = [ ] pid_container = set ( ) camid_container = set ( ) for img_path in img_paths : img_name = osp . basename ( img_path ) pid , camid , datetime , sn = img_name . split ( '-' ) camid = int ( camid ) if '_' in pid : pid , vid = pid . split ( '_' ) pid = int ( pid ) - 1 img_list . append ( ( img_path , pid , vid , camid ) ) else : pid = int ( pid ) - 1 img_list . append ( ( img_path , pid , camid ) ) pid_container . add ( pid ) camid_container . add ( camid ) num_pids = len ( pid_container ) num_train_pids , num_train_camids = num_pids // 2 , len ( camid_container ) // 2 splits = [ ] for _ in range ( 10 ) : order = np . arange ( num_pids ) np . random . shuffle ( order ) train_idxs = np . sort ( order [ : num_train_pids ] ) idx2label = { idx : label for label , idx in enumerate ( train_idxs ) } order = np . array ( list ( camid_container ) ) np . random . shuffle ( order ) cam_a_ids = np . sort ( order [ : num_train_camids ] ) train , test_a , test_b = [ ] , [ ] , [ ] for attr in img_list : if attr [ 1 ] in train_idxs : attr = list ( attr ) attr [ 1 ] = idx2label [ attr [ 1 ] ] train . append ( tuple ( attr ) ) else : if attr [ - 1 ] in cam_a_ids : test_a . append ( attr ) else : test_b . append ( attr ) split = { 'train' : train , 'query' : test_a , 'gallery' : test_b , 'num_train_pids' : num_train_pids , 'num_query_pids' : num_pids - num_train_pids , 'num_gallery_pids' : num_pids - num_train_pids } splits . append ( split ) split = { 'train' : train , 'query' : test_b , 'gallery' : test_a , 'num_train_pids' : num_train_pids , 'num_query_pids' : num_pids - num_train_pids , 'num_gallery_pids' : num_pids - num_train_pids } splits . append ( split ) print ( 'Totally {} splits are created' . format ( len ( splits ) ) ) write_json ( splits , self . split_path ) print ( 'Split file saved to {}' . format ( self . split_path ) )
Image name format: 0001001.png, where first four digits represent identity
and last four digits represent cameras.
Image name format : 0001001 . png where first four digits represent identity and last four digits represent cameras .
"""
        Image name format: 0001001.png, where first four digits represent identity
        and last four digits represent cameras. Camera 1&2 are considered the same
        view and camera 3&4 are considered the same view.
        """ # Shuffle the pids # Shuffle the camids # (img_path, pid, (vid), camid) # use cameraA as query and cameraB as gallery # use cameraB as query and cameraA as gallery
self