栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

计算miou

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

计算miou

hist = torch.zeros(n_classes, n_classes).cuda().detach()
for i, (imgs, label) in diter:
    N, _, H, W = label.shape

    label = label.squeeze(1).cuda()
    size = label.size()[-2:]

    imgs = imgs.cuda()
    ##########################################
    #   logits = YourNetwork(imgs)[0]        #
    ##########################################

    probs = torch.softmax(logits, dim=1)
    preds = torch.argmax(probs, dim=1)

    keep = label != self.ignore_label
    binc = torch.bincount(label[keep] * n_classes + preds[keep], minlength=n_classes ** 2)
    binc = binc.view(n_classes, n_classes).float()
    hist += binc
if dist.is_initialized():
    dist.all_reduce(hist, dist.ReduceOp.SUM)
ious = hist.diag() / (hist.sum(dim=0) + hist.sum(dim=1) - hist.diag())
miou = ious.mean()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/503786.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号