(gt_masks, pred_masks, ignore_label=-1)
| 23 | from utils.constants import * |
| 24 | |
| 25 | def 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 | |
| 34 | def _max_by_axis(the_list): |
| 35 | # type: (List[List[int]]) -> List[int] |
no outgoing calls
no test coverage detected