def test_mean_average_precision_and_recall_per_class(): ds_path = BASE_PATH / 'hair_drier_toaster_bear.json' df = cocoeval.generate_predictions(ds_path, ds_path) class_idx_metrics = cocoeval.mean_average_precision_and_recall_per_class(df) class_idxs = df['true_class_id'].unique() class_idxs = class_idxs[class_idxs > 0] print(class_idx_metrics) assert len(class_idx_metrics) == len(class_idxs)
def test_mean_average_precision_and_recall_per_class_with_name_min_score(): ds_path = BASE_PATH / 'hair_drier_toaster_bear.json' ds = CocoDataset(ds_path) idx_class_name = { idx: cat_meta['name'] for idx, cat_meta in ds.cats.items() } df = cocoeval.generate_predictions(ds_path, ds_path) class_idx_metrics = cocoeval.mean_average_precision_and_recall_per_class( df, idx_class_dict=idx_class_name, min_score=0.5) class_idxs = df['true_class_id'].unique() class_idxs = class_idxs[class_idxs > 0] print(class_idx_metrics) assert len(class_idx_metrics) == len(class_idxs)