def eval_ood_measure(conf, seg_label, pred, out_labels=[10], mask=None): ECE = _ECELoss() pred_ID=pred[seg_label!=out_labels[0]] seg_label_ID = seg_label[seg_label != out_labels[0]] conf_ID=conf[seg_label != out_labels[0]] ece_out = ECE.forward(conf_ID,pred_ID,seg_label_ID) conf=conf.cpu().numpy() seg_label = seg_label.cpu().numpy() if mask is not None: seg_label = seg_label[mask] out_label = seg_label == out_labels[0] for label in out_labels: out_label = np.logical_or(out_label, seg_label == label) in_scores = - conf[np.logical_not(out_label)] out_scores = - conf[out_label] print('out_label',np.sum(out_label) , np.mean(out_scores), np.mean(in_scores)) if (len(out_scores) != 0) and (len(in_scores) != 0): auroc, aupr, fpr = anom_utils.get_and_print_results(out_scores, in_scores) return auroc, aupr, fpr, ece_out.cpu().item() else: print("This image does not contain any OOD pixels or is only OOD.",out_labels ) return None
def eval_ood_measure(conf, seg_label): out_label = seg_label == 11 out_label = np.logical_or(out_label, seg_label == 11) in_scores = -conf[np.logical_not(out_label)] out_scores = -conf[out_label] if (len(out_scores) != 0) and (len(in_scores) != 0): auroc, aupr, fpr = anom_utils.get_and_print_results( out_scores, in_scores) return auroc, aupr, fpr else: print("This image does not contain any OOD pixels or is only OOD.") return None
def eval_ood_measure(conf, seg_label, cfg, mask=None): out_labels = cfg.OOD.out_label if mask is not None: seg_label = seg_label[mask] out_label = seg_label == out_labels[0] for label in out_labels: out_label = np.logical_or(out_label, seg_label == label) in_scores = - conf[np.logical_not(out_label))] out_scores = - conf[out_label] if (len(out_scores) != 0) and (len(in_scores) != 0): auroc, aupr, fpr = anom_utils.get_and_print_results(out_scores, in_scores) return auroc, aupr, fpr else: print("This image does not contain any OOD pixels or is only OOD.") return None