def city_name(self) -> str: """get city name of the current log Returns: city_name: city name of the current log, either 'PIT' or 'MIA' """ return read_city_name( os.path.join(self.root_dir, self.current_log, "city_info.json"))
def get_city_name(self, log_id: str) -> str: """ Args: log_id: str Returns: city_name: str """ city_info_fpath = f"{self.data_dir}/{log_id}/city_info.json" city_name = read_city_name(city_info_fpath) assert isinstance(city_name, str) return city_name
def get_city_name(self, log_id: str) -> str: """Return the name of the city where the log of interest was captured. Args: log_id: str Returns: city_name: str """ city_info_fpath = f"{self.data_dir}/{log_id}/city_info.json" city_name = read_city_name(city_info_fpath) assert isinstance(city_name, str) return city_name
def accumulate( dt_root_fpath: Path, gt_fpath: Path, cfg: DetectionCfg, avm: Optional[ArgoverseMap] ) -> Tuple[DefaultDict[str, np.ndarray], DefaultDict[str, int]]: """Accumulate the true/false positives (boolean flags) and true positive errors for each class. Args: dt_root_fpath: Detections root folder file path. gt_fpath: Ground truth file path. cfg: Detection configuration. Returns: cls_to_accum: Class to accumulated statistics dictionary of shape |C| -> (N, K + S) where C is the number of detection classes, K is the number of true positive thresholds used for AP computation, and S is the number of true positive errors. cls_to_ninst: Mapping of shape |C| -> (1,) the class names to the number of instances in the ground truth dataset. """ log_id = gt_fpath.parents[1].stem logger.info(f"log_id = {log_id}") ts = int(gt_fpath.stem.split("_")[-1]) dt_fpath = dt_root_fpath / f"{log_id}/per_sweep_annotations_amodal/" f"tracked_object_labels_{ts}.json" dts = np.array(read_label(str(dt_fpath))) gts = np.array(read_label(str(gt_fpath))) if cfg.eval_only_roi_instances and avm is not None: # go up 3 levels, because hierarchy is as follows: # {gt_root_fpath}/{log_id}/per_sweep_annotations_amodal/{gt_root_fname} gt_root_fpath = Path(gt_fpath).parents[2] city_SE3_egovehicle = get_city_SE3_egovehicle_at_sensor_t( ts, str(gt_root_fpath), log_id) if city_SE3_egovehicle is not None: log_city_name = read_city_name( os.path.join(gt_root_fpath, log_id, "city_info.json")) dts = filter_objs_to_roi(dts, avm, city_SE3_egovehicle, log_city_name) gts = filter_objs_to_roi(gts, avm, city_SE3_egovehicle, log_city_name) cls_to_accum = defaultdict(list) cls_to_ninst = defaultdict(int) for class_name in cfg.dt_classes: dt_filtered = filter_instances( dts, class_name, filter_metric=cfg.dt_metric, max_detection_range=cfg.max_dt_range, ) gt_filtered = filter_instances( gts, class_name, filter_metric=cfg.dt_metric, max_detection_range=cfg.max_dt_range, ) gt_filtered = remove_duplicate_instances(gt_filtered, cfg) logger.info(f"{dt_filtered.shape[0]} detections") logger.info(f"{gt_filtered.shape[0]} ground truth") if dt_filtered.shape[0] > 0: ranked_detections, scores = rank(dt_filtered) metrics = assign(ranked_detections, gt_filtered, cfg) cls_to_accum[class_name] = np.hstack((metrics, scores)) cls_to_ninst[class_name] = gt_filtered.shape[0] return cls_to_accum, cls_to_ninst