CFA_for_anomaly_localization icon indicating copy to clipboard operation
CFA_for_anomaly_localization copied to clipboard

error when training own database

Open vuhungtvt2018 opened this issue 2 years ago • 3 comments

image

vuhungtvt2018 avatar Jan 31 '23 04:01 vuhungtvt2018

please help me reslove this problem. I don't khown what this error is

vuhungtvt2018 avatar Jan 31 '23 04:01 vuhungtvt2018

I also ran into this problem, and here's my solution:

utils/metric.py

def get_threshold(gt, score):
    gt_mask = np.asarray(gt)
    gt_mask_copy = gt_mask.copy()
    gt_mask[gt_mask_copy < 0.5] = 0
    gt_mask[gt_mask_copy >= 0.5] = 1
    # print(gt_mask.flatten())
    precision, recall, thresholds = precision_recall_curve(gt_mask.flatten(), score.flatten())
    a = 2 * precision * recall
    b = precision + recall
    f1 = np.divide(a, b, out=np.zeros_like(a), where=b != 0)
    threshold = thresholds[np.argmax(f1)]

    return threshold```

wangxiang0722 avatar Jan 31 '23 09:01 wangxiang0722

@wangxiang0722 thank very much. i try use your workaround

vuhungtvt2018 avatar Jan 31 '23 09:01 vuhungtvt2018