MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / get_iou

Function get_iou

semantic_sam/utils/misc.py:25–32  ·  view source on GitHub ↗
(gt_masks, pred_masks, ignore_label=-1)

Source from the content-addressed store, hash-verified

23from utils.constants import *
24
25def get_iou(gt_masks, pred_masks, ignore_label=-1):
26 rev_ignore_mask = ~(gt_masks == ignore_label)
27 gt_masks = gt_masks.bool()
28 n,h,w = gt_masks.shape
29 intersection = ((gt_masks & pred_masks) & rev_ignore_mask).reshape(n,h*w).sum(dim=-1)
30 union = ((gt_masks | pred_masks) & rev_ignore_mask).reshape(n,h*w).sum(dim=-1)
31 ious = (intersection / union)
32 return ious
33
34def _max_by_axis(the_list):
35 # type: (List[List[int]]) -> List[int]

Callers 2

evaluate_interactiveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected