MCPcopy Create free account
hub / github.com/DingLei14/WiCoNet / evaluate

Function evaluate

utils/misc.py:50–62  ·  view source on GitHub ↗
(predictions, gts, num_classes)

Source from the content-addressed store, hash-verified

48
49
50def evaluate(predictions, gts, num_classes):
51 hist = np.zeros((num_classes, num_classes))
52 for lp, lt in zip(predictions, gts):
53 hist += _fast_hist(lp.flatten(), lt.flatten(), num_classes)
54 # axis 0: gt, axis 1: prediction
55 acc = np.diag(hist).sum() / hist.sum()
56 acc_cls = np.diag(hist) / hist.sum(axis=1)
57 acc_cls = np.nanmean(acc_cls)
58 iu = np.diag(hist) / (hist.sum(axis=1) + hist.sum(axis=0) - np.diag(hist))
59 mean_iu = np.nanmean(iu)
60 freq = hist.sum(axis=1) / hist.sum()
61 fwavacc = (freq[freq > 0] * iu[freq > 0]).sum()
62 return acc, acc_cls, mean_iu, fwavacc
63
64
65class PolyLR(object):

Callers

nothing calls this directly

Calls 1

_fast_histFunction · 0.85

Tested by

no test coverage detected