Skip to content

Commit

Permalink
fix coco evaluation (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcakyon authored Sep 13, 2021
1 parent 7733fc3 commit b282843
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sahi/scripts/coco_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def evaluate_coco(
cocoEval = COCOeval(cocoGt, cocoDt, iou_type)
cocoEval.params.catIds = cat_ids
cocoEval.params.maxDets = list(proposal_nums)
cocoEval.params.iouThrs = [iou_thrs] if not isinstance(iou_thrs, list) else iou_thrs
cocoEval.params.iouThrs = (
[iou_thrs] if not isinstance(iou_thrs, list) and not isinstance(iou_thrs, np.ndarray) else iou_thrs
)
# mapping of cocoEval.stats
coco_metric_names = {
"mAP": 0,
Expand Down Expand Up @@ -331,17 +333,17 @@ def evaluate_coco(
def main(
dataset_json_path: str,
result_json_path: str,
out_dir: str,
out_dir: str = None,
type: str = "bbox",
classwise: bool = False,
proposal_nums: List[int] = [1024, 9216, 10000000000],
proposal_nums: List[int] = [10, 100, 500],
iou_thrs: Union[List[float], float] = None,
):
"""
Args:
dataset_json_path (str): file path for the coco dataset json file
result_json_path (str): file path for the coco result json file
out_dir (str): dir to save analyze result images
out_dir (str): dir to save eval result
type (bool): 'bbox' or 'mask'
classwise (bool): whether to evaluate the AP for each class
proposal_nums (List[int]): Proposal number used for evaluating recalls, such as recall@100, recall@500
Expand Down

0 comments on commit b282843

Please sign in to comment.