-
7/21 - [17/10K] - preds = model(sweep_imgs, mats, ...)개발일지 2024. 7. 22. 00:46
쉽지 않다.......
아래 처럼 실행 후 preds를 구해도 128x128의 값이기 때문에 다시 박스를 계산해야한다.
model = model.to(device) preds = model(sweep_imgs, mats, pts_pv=pts_pv, is_train=False)
너무 복잡하다 이게 하나의 로직이다.
단순 그냥 박스 그리는것이 아니였다. 쩝......
def eval_step(self, batch, batch_idx, prefix: str): (sweep_imgs, mats, img_metas, _, _, _, _, pts_pv) = batch if torch.cuda.is_available(): if self.return_image: sweep_imgs = sweep_imgs.cuda() for key, value in mats.items(): mats[key] = value.cuda() if self.return_radar_pv: pts_pv = pts_pv.cuda() preds = self(sweep_imgs, mats, pts_pv=pts_pv, is_train=False) if isinstance(self.model, torch.nn.parallel.DistributedDataParallel): results = self.model.module.get_bboxes(preds, img_metas) else: results = self.model.get_bboxes(preds, img_metas) for i in range(len(results)): results[i][0] = results[i][0].tensor.detach().cpu().numpy() results[i][1] = results[i][1].detach().cpu().numpy() results[i][2] = results[i][2].detach().cpu().numpy() results[i].append(img_metas[i]) return results def test_epoch_end(self, test_step_outputs): all_pred_results = list() all_img_metas = list() for test_step_output in test_step_outputs: for i in range(len(test_step_output)): all_pred_results.append(test_step_output[i][:3]) all_img_metas.append(test_step_output[i][3]) synchronize() # TODO: Change another way. dataset_length = len(self.val_dataloader().dataset) all_pred_results = sum( map(list, zip(*all_gather_object(all_pred_results))), [])[:dataset_length] all_img_metas = sum(map(list, zip(*all_gather_object(all_img_metas))), [])[:dataset_length] if self.global_rank == 0: self.evaluator.evaluate(all_pred_results, all_img_metas) def evaluate( self, results, img_metas, metric='bbox', logger=None, jsonfile_prefix=None, result_names=['img_bbox'], show=False, out_dir=None, pipeline=None, ): """Evaluation in nuScenes protocol. Args: results (list[dict]): Testing results of the dataset. metric (str | list[str]): Metrics to be evaluated. logger (logging.Logger | str | None): Logger used for printing related information during evaluation. Default: None. jsonfile_prefix (str | None): The prefix of json files. It includes the file path and the prefix of filename, e.g., "a/b/prefix". If not specified, a temp file will be created. Default: None. show (bool): Whether to visualize. Default: False. out_dir (str): Path to save the visualization results. Default: None. pipeline (list[dict], optional): raw data loading for showing. Default: None. Returns: dict[str, float]: Results of each evaluation metric. """ result_files, tmp_dir = self.format_results(results, img_metas, result_names, jsonfile_prefix)
반응형'개발일지' 카테고리의 다른 글
7/27 - [20/10K] - CRN, SparseDrive (0) 2024.07.27 7/24 - [18/10K] - Sparse4D (0) 2024.07.25 7/17 - [15/10K] - __getitem__, collate_fn 역할 (0) 2024.07.17 [7/16, 13/10K] - 가중치 초기화 설명(Kaiming, Xavier) (0) 2024.07.16 7/10 - [11/10K] - nuscene 이미지 저장 (0) 2024.07.10