Test model with single gpu. This method tests model with single gpu and gives the 'show' option. By setting ``show=True``, it saves the visualization results under ``out_dir``. Args: model (nn.Module): Model to be tested. data_loader (nn.Dataloader): Pytorch
(model,
data_loader,
show=False,
out_dir=None,
show_score_thr=0.3)
| 140 | 'flow_results': flow_results} |
| 141 | |
| 142 | def collect_results_cpu(result_part, size, tmpdir=None): |
| 143 | rank, world_size = get_dist_info() |
| 144 | # create a tmp dir if it is not specified |
| 145 | if tmpdir is None: |
| 146 | MAX_LEN = 512 |
| 147 | # 32 is whitespace |
| 148 | dir_tensor = torch.full((MAX_LEN, ), |
| 149 | 32, |
| 150 | dtype=torch.uint8, |
| 151 | device='cuda') |
| 152 | if rank == 0: |
| 153 | mmcv.mkdir_or_exist('.dist_test') |
| 154 | tmpdir = tempfile.mkdtemp(dir='.dist_test') |
| 155 | tmpdir = torch.tensor( |
| 156 | bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') |
| 157 | dir_tensor[:len(tmpdir)] = tmpdir |
| 158 | dist.broadcast(dir_tensor, 0) |
| 159 | tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() |
| 160 | else: |
| 161 | mmcv.mkdir_or_exist(tmpdir) |
| 162 | # dump the part result to the dir |
| 163 | mmcv.dump(result_part, osp.join(tmpdir, f'part_{rank}.pkl')) |
| 164 | dist.barrier() |
| 165 | # collect all parts |
| 166 | if rank != 0: |
| 167 | return None |
| 168 | else: |
| 169 | # load results of all parts from tmp dir |
| 170 | part_list = [] |
| 171 | for i in range(world_size): |
| 172 | part_file = osp.join(tmpdir, f'part_{i}.pkl') |
| 173 | part_list.append(mmcv.load(part_file)) |
| 174 | # sort the results |
| 175 | ordered_results = [] |
| 176 | ''' |
| 177 | bacause we change the sample of the evaluation stage to make sure that each gpu will handle continuous sample, |
| 178 | ''' |
| 179 | #for res in zip(*part_list): |
| 180 | for res in part_list: |
nothing calls this directly
no outgoing calls
no test coverage detected