(predictions, gts, num_classes)
| 48 | |
| 49 | |
| 50 | def 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 | |
| 65 | class PolyLR(object): |
nothing calls this directly
no test coverage detected