diff --git a/encoding/utils/metrics.py b/encoding/utils/metrics.py index f14ecc9c..4e08d672 100644 --- a/encoding/utils/metrics.py +++ b/encoding/utils/metrics.py @@ -24,11 +24,11 @@ def accuracy(output, target, topk=(1,)): _, pred = output.topk(maxk, 1, True, True) pred = pred.t() - correct = pred.eq(target.view(1, -1).expand_as(pred)) + correct = pred.eq(target.reshape(1, -1).expand_as(pred)) res = [] for k in topk: - correct_k = correct[:k].view(-1).float().sum(0, keepdim=True) + correct_k = correct[:k].reshape(-1).float().sum(0, keepdim=True) res.append(correct_k.mul_(100.0 / batch_size)) return res @@ -37,6 +37,12 @@ def get_pixacc_miou(total_correct, total_label, total_inter, total_union): IoU = 1.0 * total_inter / (np.spacing(1) + total_union) mIoU = IoU.mean() return pixAcc, mIoU + +def get_pixacc_miou(total_correct, total_label, total_inter, total_union): + pixAcc = 1.0 * total_correct / (np.spacing(1) + total_label) + IoU = 1.0 * total_inter / (np.spacing(1) + total_union) + mIoU = IoU.mean() + return pixAcc, mIoU class SegmentationMetric(object): diff --git a/scripts/prepare_minc.py b/scripts/prepare_minc.py index fc37d91e..5d447e8f 100644 --- a/scripts/prepare_minc.py +++ b/scripts/prepare_minc.py @@ -20,7 +20,7 @@ def parse_args(): def download_minc(path, overwrite=False): _AUG_DOWNLOAD_URLS = [ - ('http://opensurfaces.cs.cornell.edu/static/minc/minc-2500.tar.gz', 'bcccbb3b1ab396ef540f024a5ba23eff54f7fe31')] + ('https://web.archive.org/web/20190605124855/http://opensurfaces.cs.cornell.edu/static/minc/minc-2500.tar.gz', 'bcccbb3b1ab396ef540f024a5ba23eff54f7fe31')] download_dir = os.path.join(path, 'downloads') mkdir(download_dir) for url, checksum in _AUG_DOWNLOAD_URLS: