Open lr1234567 opened 3 years ago
def hist_info(pred, label, num_cls): assert pred.shape == label.shape k = (label >= 0) & (label < num_cls) labeled = np.sum(k) correct = np.sum((pred[k] == label[k]))
return np.bincount(num_cls * label[k].astype(int) + pred[k], minlength=num_cls ** 2).reshape(num_cls,
num_cls), labeled, correct
def compute_score(hist, correct, labeled): iu = np.diag(hist) / (hist.sum(1) + hist.sum(0) - np.diag(hist)) mean_IU = np.nanmean(iu) mean_IU_no_back = np.nanmean(iu[1:]) freq = hist.sum(1) / hist.sum() freq_IU = (iu[freq > 0] * freq[freq > 0]).sum() mean_pixel_acc = correct / labeled
return iu, mean_IU, mean_IU_no_back, mean_pixel_acc
Hello, I want to calculate freq_ IU is used as evaluation index, but I don't know how to use these two functions?
You can put the code here.