国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

語義分割混淆矩陣、 mIoU、mPA計(jì)算

這篇具有很好參考價(jià)值的文章主要介紹了語義分割混淆矩陣、 mIoU、mPA計(jì)算。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

語義分割混淆矩陣、 mIoU、mPA計(jì)算,windows,服務(wù)器,linux

一、操作

import cv2 
img_gray = cv2.imread("nezha.jpg",cv2.IMREAD_GRAYSCALE)
for i in range(22):
    dst = cv2.applyColorMap(img_gray,i) 
    cv2.imshow('map',dst) 
    cv2.waitKey(500)
    cv2.imwrite("map-"+str(i)+".jpg",dst)

需要會調(diào)試代碼的人自己改,小白直接運(yùn)行會出錯(cuò)

這是我從自己的大文件里摘取的一部分代碼,可以運(yùn)行,只是要改的文件地址path比較多,遇到雙引號“”的地址注意一下,不然地址不對容易出錯(cuò)

?把?calculate.py和?utiles_metrics.py放在同一文件夾下,然后運(yùn)行?calculate.py。

二、理解

test_mIou,test_mPA,test_miou,test_mpa=compute_mIoU(gt_dir, pred_dir, image_ids, num_classes, name_classes,weight_name)  # 執(zhí)行計(jì)算mIoU的函數(shù)

gt_dir 真實(shí)標(biāo)簽文件夾

pred_dir?預(yù)測結(jié)果文件夾

主要是這兩個(gè)變量設(shè)置,后面的可以選擇性修改

image_ids 文件名稱?dirList(pred_dir,path_list) saveList(path_list) 這兩個(gè)函數(shù)得到

num_classes 類別數(shù)

name_classes 類別名稱

weight_name 權(quán)重名稱

hist為混淆矩陣,mIoU為交并比

三、代碼?

?calculate.py

# -*- coding: utf-8 -*-
import torch
import os

from time import time
# from PIL import Image
from utils_metrics import compute_mIoU
def saveList(pathName):
    for file_name in pathName:
        #f=open("C:/Users/Administrator/Desktop/DeepGlobe-Road-Extraction-link34-py3/dataset/real/gt.txt", "x")
        with open("./dataset/gt.txt", "a") as f:
            f.write(file_name.split(".")[0] + "\n")
        f.close

def dirList(gt_dir,path_list):
    for i in range(0, len(path_list)):
        path = os.path.join(gt_dir, path_list[i])
    if os.path.isdir(path):
        saveList(os.listdir(path))

data_path  = './dataset/'


f=open("./dataset/gt.txt", 'w')
gt_dir      = os.path.join(data_path, "real/")
pred_dir    = "./submits/log01_Dink101_five_100/test_iou/iou_60u/"
path_list = os.listdir(pred_dir)
path_list.sort()
dirList(pred_dir,path_list)
saveList(path_list)
num_classes=2
name_classes    = ["nontarget","target"]
weight_name='log01_Dink101_five_100'
image_ids   = open(os.path.join(data_path, "gt.txt"),'r').read().splitlines() 

test_mIou,test_mPA,test_miou,test_mpa=compute_mIoU(gt_dir, pred_dir, image_ids, num_classes, name_classes,weight_name)  # 執(zhí)行計(jì)算mIoU的函數(shù)
print('  test_mIoU:  '+str(test_miou))

?utiles_metrics.py

from os.path import join

import numpy as np
import torch
import torch.nn.functional as F
from PIL import Image
import os
import cv2

# from matplotlib import pyplot as plt
import shutil
import numpy as np
# from matplotlib.pyplot import MultipleLocator

def f_score(inputs, target, beta=1, smooth = 1e-5, threhold = 0.5):
    n, c, h, w = inputs.size()
    nt, ht, wt, ct = target.size()
    if h != ht and w != wt:
        inputs = F.interpolate(inputs, size=(ht, wt), mode="bilinear", align_corners=True)
        
    temp_inputs = torch.softmax(inputs.transpose(1, 2).transpose(2, 3).contiguous().view(n, -1, c),-1)
    temp_target = target.view(n, -1, ct)

    #--------------------------------------------#
    #   計(jì)算dice系數(shù)
    #--------------------------------------------#
    temp_inputs = torch.gt(temp_inputs, threhold).float()
    tp = torch.sum(temp_target[...,:-1] * temp_inputs, axis=[0,1])
    fp = torch.sum(temp_inputs                       , axis=[0,1]) - tp
    fn = torch.sum(temp_target[...,:-1]              , axis=[0,1]) - tp

    score = ((1 + beta ** 2) * tp + smooth) / ((1 + beta ** 2) * tp + beta ** 2 * fn + fp + smooth)
    score = torch.mean(score)
    return score

# 設(shè)標(biāo)簽寬W,長H
def fast_hist(a, b, n):
    #--------------------------------------------------------------------------------#
    #   a是轉(zhuǎn)化成一維數(shù)組的標(biāo)簽,形狀(H×W,);b是轉(zhuǎn)化成一維數(shù)組的預(yù)測結(jié)果,形狀(H×W,)
    #--------------------------------------------------------------------------------#
    k = (a >= 0) & (a < n)
    #--------------------------------------------------------------------------------#
    #   np.bincount計(jì)算了從0到n**2-1這n**2個(gè)數(shù)中每個(gè)數(shù)出現(xiàn)的次數(shù),返回值形狀(n, n)
    #   返回中,寫對角線上的為分類正確的像素點(diǎn)
    #--------------------------------------------------------------------------------#
    return np.bincount(n * a[k].astype(int) + b[k], minlength=n ** 2).reshape(n, n)  

def per_class_iu(hist):
    return np.diag(hist) / np.maximum((hist.sum(1) + hist.sum(0) - np.diag(hist)), 1) 

def per_class_PA(hist):
    return np.diag(hist) / np.maximum(hist.sum(1), 1) 

def compute_mIoU(gt_dir, pred_dir, png_name_list, num_classes, name_classes,weight_name):  
    # print('Num classes', num_classes)  
    #-----------------------------------------#
    #   創(chuàng)建一個(gè)全是0的矩陣,是一個(gè)混淆矩陣
    #-----------------------------------------#
    hist = np.zeros((num_classes, num_classes))
    
    #------------------------------------------------#
    #   獲得驗(yàn)證集標(biāo)簽路徑列表,方便直接讀取
    #   獲得驗(yàn)證集圖像分割結(jié)果路徑列表,方便直接讀取
    #------------------------------------------------#
    gt_imgs     = [join(gt_dir, x + ".png") for x in png_name_list]  
    pred_imgs   = [join(pred_dir, x + ".png") for x in png_name_list]  
    # building_iou=[]
    # background_iou=[]
    m_iou=[]
    # building_pa=[]
    # background_pa=[]
    m_pa=[]

    #------------------------------------------------#
    #   讀取每一個(gè)(圖片-標(biāo)簽)對
    #------------------------------------------------#
    for ind in range(len(gt_imgs)): 
        #------------------------------------------------#
        #   讀取一張圖像分割結(jié)果,轉(zhuǎn)化成numpy數(shù)組
        #------------------------------------------------#
        pred = np.array(Image.open(pred_imgs[ind]))
        
        #------------------------------------------------#
        #   讀取一張對應(yīng)的標(biāo)簽,轉(zhuǎn)化成numpy數(shù)組
        #------------------------------------------------#
        label = np.array(Image.open(gt_imgs[ind]))  
        
        # 如果圖像分割結(jié)果與標(biāo)簽的大小不一樣,這張圖片就不計(jì)算
        if len(label.flatten()) != len(pred.flatten()):  
            print(
                'Skipping: len(gt) = {:d}, len(pred) = {:d}, {:s}, {:s}'.format(
                    len(label.flatten()), len(pred.flatten()), gt_imgs[ind],
                    pred_imgs[ind]))
            continue

        #------------------------------------------------#
        #   對一張圖片計(jì)算21×21的hist矩陣,并累加
        #------------------------------------------------#
        a=label.flatten()
        a//=254
       
        b=pred.flatten()
        b//=254
        hist += fast_hist(a, b,num_classes)  
        # # 每計(jì)算10張就輸出一下目前已計(jì)算的圖片中所有類別平均的mIoU值
        # mIoUs   = per_class_iu(hist)
        # mPA     = per_class_PA(hist)
        # m_iou.append(100 * np.nanmean(mIoUs[1]))
        # m_pa.append(100 * np.nanmean(mPA[1]))
        # # if ind > 0 and ind % 10 == 0:  
        # #     print('{:d} / {:d}: mIou-{:0.2f}; mPA-{:0.2f}'.format(ind, len(gt_imgs),
        # #                                             100 * np.nanmean(mIoUs[1]),
        # #                                             100 * np.nanmean(mPA[1])))
    mIoUs   = per_class_iu(hist)
    mPA     = per_class_PA(hist)
    print(mIoUs)

    # plt.figure()
    # x=np.arange(len(m_iou))
    # plt.plot(x,m_iou)
    # plt.plot(x,m_pa)
    # plt.grid(True)
    # y_major_locator=MultipleLocator(10)#把y軸的刻度間隔設(shè)置為10,并存在變量里
    # ax = plt.gca()
    # ax.yaxis.set_major_locator(y_major_locator)
    # ax.set_ylim(0,100)
    # plt.xlabel('Order')
    # plt.ylabel('mIOU & mPA')
    # plt.legend(['mIOU','mPA'],loc="upper right")

    # targ=os.path.join(pred_dir,os.path.pardir)
    

    # plt.savefig(os.path.join(targ, weight_name[:-3]+"_sin_miou.png"))

    return m_iou,m_pa,str(round(mIoUs[1] * 100, 2)),str(round(mPA[1] * 100, 2))

調(diào)試

語義分割混淆矩陣、 mIoU、mPA計(jì)算,windows,服務(wù)器,linux

個(gè)人使用文章來源地址http://www.zghlxwxcb.cn/news/detail-579263.html

import os
import shutil
data_path='./submits/log01_Dink101_five_100/test_iou/'
data=open(os.path.join(data_path, "log01_Dink101_five_100_excel.txt"),'r').read().splitlines()
valid_path='./dataset/valid/'
real_path='./dataset/real/'
 
iou_100=os.path.join(data_path,'iou_60u/')
iou_80=os.path.join(data_path,'iou_60d/')

if not os.path.exists(iou_100):
    os.mkdir(iou_100)
    os.mkdir(iou_80)

for n in data:
    name=n.split()[1]
    iou=float(n.split()[2])
    if iou>=65:
        img_path=os.path.join(data_path,'87.650/'+name+'.png')

        
        shutil.copy(img_path,iou_100)

        
        print(name,iou)
        continue
    else :
        img_path=os.path.join(data_path,'87.650/'+name+'.png')
        
        shutil.copy(img_path,iou_80)
       
        print(name,iou)
        continue
 
print('Finish')

# -*- coding: utf-8 -*-
import torch
import os

from time import time
# from PIL import Image
from utils.utils_metrics import compute_mIoU
from utils.utils_metrics import compute_IoU
def saveList(pathName):
    for file_name in pathName:
        #f=open("C:/Users/Administrator/Desktop/DeepGlobe-Road-Extraction-link34-py3/dataset/real/gt.txt", "x")
        with open("./dataset/gt.txt", "a") as f:
            f.write(file_name.split(".")[0] + "\n")
        f.close

def dirList(gt_dir,path_list):
    for i in range(0, len(path_list)):
        path = os.path.join(gt_dir, path_list[i])
    if os.path.isdir(path):
        saveList(os.listdir(path))

data_path  = './dataset/'


f=open("./dataset/gt.txt", 'w')
gt_dir      = os.path.join(data_path, "real/")
pred_dir    = "./submits/log01_Dink101_five_100/test_iou/iou_60u/"
path_list = os.listdir(pred_dir)
path_list.sort()
dirList(pred_dir,path_list)
saveList(path_list)
num_classes=2
name_classes    = ["nontarget","target"]
weight_name='log01_Dink101_five_100'
image_ids   = open(os.path.join(data_path, "gt.txt"),'r').read().splitlines() 

# compute_IoU(gt_dir, pred_dir, image_ids, num_classes, weight_name)
test_mIou,test_mPA,test_miou,test_mpa=compute_mIoU(gt_dir, pred_dir, image_ids, num_classes, name_classes,weight_name)  # 執(zhí)行計(jì)算mIoU的函數(shù)
print('  test_mIoU:  '+str(test_miou))
from os.path import join

import numpy as np
import torch
import torch.nn.functional as F
from PIL import Image
import os
import cv2

# from matplotlib import pyplot as plt
import shutil
import numpy as np
# from matplotlib.pyplot import MultipleLocator

def f_score(inputs, target, beta=1, smooth = 1e-5, threhold = 0.5):
    n, c, h, w = inputs.size()
    nt, ht, wt, ct = target.size()
    if h != ht and w != wt:
        inputs = F.interpolate(inputs, size=(ht, wt), mode="bilinear", align_corners=True)
        
    temp_inputs = torch.softmax(inputs.transpose(1, 2).transpose(2, 3).contiguous().view(n, -1, c),-1)
    temp_target = target.view(n, -1, ct)

    #--------------------------------------------#
    #   計(jì)算dice系數(shù)
    #--------------------------------------------#
    temp_inputs = torch.gt(temp_inputs, threhold).float()
    tp = torch.sum(temp_target[...,:-1] * temp_inputs, axis=[0,1])
    fp = torch.sum(temp_inputs                       , axis=[0,1]) - tp
    fn = torch.sum(temp_target[...,:-1]              , axis=[0,1]) - tp

    score = ((1 + beta ** 2) * tp + smooth) / ((1 + beta ** 2) * tp + beta ** 2 * fn + fp + smooth)
    score = torch.mean(score)
    return score

# 設(shè)標(biāo)簽寬W,長H
def fast_hist(a, b, n):
    #--------------------------------------------------------------------------------#
    #   a是轉(zhuǎn)化成一維數(shù)組的標(biāo)簽,形狀(H×W,);b是轉(zhuǎn)化成一維數(shù)組的預(yù)測結(jié)果,形狀(H×W,)
    #--------------------------------------------------------------------------------#
    k = (a >= 0) & (a < n)
    #--------------------------------------------------------------------------------#
    #   np.bincount計(jì)算了從0到n**2-1這n**2個(gè)數(shù)中每個(gè)數(shù)出現(xiàn)的次數(shù),返回值形狀(n, n)
    #   返回中,寫對角線上的為分類正確的像素點(diǎn)
    #--------------------------------------------------------------------------------#
    return np.bincount(n * a[k].astype(int) + b[k], minlength=n ** 2).reshape(n, n)  

def per_class_iu(hist):
    return np.diag(hist) / np.maximum((hist.sum(1) + hist.sum(0) - np.diag(hist)), 1) 

def per_class_PA(hist):
    return np.diag(hist) / np.maximum(hist.sum(1), 1) 

def compute_IoU(gt_dir, pred_dir, png_name_list, num_classes,weight_name):  
    # print('Num classes')  
    #-----------------------------------------#
    #   創(chuàng)建一個(gè)全是0的矩陣,是一個(gè)混淆矩陣
    #-----------------------------------------#
    # hist = np.zeros((num_classes, num_classes))
    
    #------------------------------------------------#
    #   獲得驗(yàn)證集標(biāo)簽路徑列表,方便直接讀取
    #   獲得驗(yàn)證集圖像分割結(jié)果路徑列表,方便直接讀取
    #------------------------------------------------#
    gt_imgs     = [join(gt_dir, x + "_mask.png") for x in png_name_list]  
    pred_imgs   = [join(pred_dir, x + ".png") for x in png_name_list]  

    m_iou=[]
    m_pa=[]
    hist_save=[] 
    
    #------------------------------------------------#
    #   讀取每一個(gè)(圖片-標(biāo)簽)對
    #------------------------------------------------#
    for ind in range(len(gt_imgs)): 

        #------------------------------------------------#
        #   讀取一張圖像分割結(jié)果,轉(zhuǎn)化成numpy數(shù)組
        #------------------------------------------------#
        pred = np.array(Image.open(pred_imgs[ind]).convert('L'))
        # pred = pred/255
        #------------------------------------------------#
        #   讀取一張對應(yīng)的標(biāo)簽,轉(zhuǎn)化成numpy數(shù)組
        #------------------------------------------------#
        label = np.array(Image.open(gt_imgs[ind]).convert('L'))  
        # label = label/255
        # 如果圖像分割結(jié)果與標(biāo)簽的大小不一樣,這張圖片就不計(jì)算
        if len(label.flatten()) != len(pred.flatten()):  
            print(
                'Skipping: len(gt) = {:d}, len(pred) = {:d}, {:s}, {:s}'.format(
                    len(label.flatten()), len(pred.flatten()), gt_imgs[ind],
                    pred_imgs[ind]))
            continue

        #------------------------------------------------#
        #   對一張圖片計(jì)算21×21的hist矩陣,并累加
        #------------------------------------------------#
        a=label.flatten()
        a//=254
        # for i in range(len(a)):
        #     a[i]=a[i]/255
        
        b=pred.flatten()
        b//=254
        # for i in range(len(b)):
        #     b[i]=b[i]/255
        hist = fast_hist(a, b,num_classes)  
        # 每計(jì)算10張就輸出一下目前已計(jì)算的圖片中所有類別平均的mIoU值
        mIoUs   = per_class_iu(hist)
        mPA     = per_class_PA(hist)
        mIoU_one = 100 * np.nanmean(mIoUs[1])
        mPA_one = 100 * np.nanmean(mPA[1])
        # if mIoU_one<80:
        #     shutil.copy(pred_imgs[ind],lower_iou)
        #     count=count+1
        # else:
        #     shutil.copy(pred_imgs[ind],higher_iou)
        img_name= png_name_list[ind]
        # if ind > 0 and ind % 10 == 0:  
        #print('{:d}  {}: Iou-{:0.2f}; PA-{:0.2f}'.format(ind,img_name,mIoU_one,mPA_one))
        #print(hist)
        m_iou.append(100 * np.nanmean(mIoUs[1]))
        m_pa.append(100 * np.nanmean(mPA[1]))
        hist_save.append(hist)
        targ=os.path.join(pred_dir,os.path.pardir)
        if ind==0:
            with open(os.path.join(targ, weight_name[:-3]+'.txt'),'w') as f:
                f.write(str(ind) +'  '+ str(img_name) +'   ')
                f.write('Iou:'+str(round(mIoU_one,2))+'  '+'PA:'+str(round(mPA_one,2))+'\n')
                f.write('                   '+'['+str(hist[0,0])+'   '+str(hist[0,1])+'\n')
                f.write('                   '+' '+str(hist[1,0])+'   '+str(hist[1,1])+']'+'\n')
            with open(os.path.join(targ, weight_name[:-3]+'_excel.txt'),'w') as f:
                f.write(str(ind) +'  '+ str(img_name) +'   ')
                f.write(str(round(mIoU_one,2))+'  '+str(round(mPA_one,2))+'\n')
        else:
            with open(os.path.join(targ, weight_name[:-3]+'.txt'),'a') as f:
                f.write(str(ind) +'  '+ str(img_name) +'   ')
                f.write('Iou:'+str(round(mIoU_one,2))+'  '+'PA:'+str(round(mPA_one,2))+'\n')
                f.write('                   '+'['+str(hist[0,0])+'   '+str(hist[0,1])+'\n')
                f.write('                   '+' '+str(hist[1,0])+'   '+str(hist[1,1])+']'+'\n')
            with open(os.path.join(targ, weight_name[:-3]+'_excel.txt'),'a') as f:
                f.write(str(ind) +'  '+ str(img_name) +'   ')
                f.write(str(round(mIoU_one,2))+'  '+str(round(mPA_one,2))+'\n')
    '''
    plt.figure()
    x=np.arange(len(m_iou))
    plt.plot(x,m_iou)
    plt.plot(x,m_pa)
    plt.grid(True)
    plt.xlabel('Order')
    plt.ylabel('test mIOU & mPA')
    plt.legend(['mIOU','mPA'],loc="upper right")

    plt.savefig(os.path.join(pred_dir[0:-13], weight_name[:-3]+"_test_iou.png"))
    '''

def compute_mIoU(gt_dir, pred_dir, png_name_list, num_classes, name_classes,weight_name):  
    # print('Num classes', num_classes)  
    #-----------------------------------------#
    #   創(chuàng)建一個(gè)全是0的矩陣,是一個(gè)混淆矩陣
    #-----------------------------------------#
    hist = np.zeros((num_classes, num_classes))
    
    #------------------------------------------------#
    #   獲得驗(yàn)證集標(biāo)簽路徑列表,方便直接讀取
    #   獲得驗(yàn)證集圖像分割結(jié)果路徑列表,方便直接讀取
    #------------------------------------------------#
    gt_imgs     = [join(gt_dir, x + "_mask.png") for x in png_name_list]  
    pred_imgs   = [join(pred_dir, x + ".png") for x in png_name_list]  
    # building_iou=[]
    # background_iou=[]
    m_iou=[]
    # building_pa=[]
    # background_pa=[]
    m_pa=[]

    #------------------------------------------------#
    #   讀取每一個(gè)(圖片-標(biāo)簽)對
    #------------------------------------------------#
    for ind in range(len(gt_imgs)): 
        #------------------------------------------------#
        #   讀取一張圖像分割結(jié)果,轉(zhuǎn)化成numpy數(shù)組
        #------------------------------------------------#
        pred = np.array(Image.open(pred_imgs[ind]).convert('L'))
        
        #------------------------------------------------#
        #   讀取一張對應(yīng)的標(biāo)簽,轉(zhuǎn)化成numpy數(shù)組
        #------------------------------------------------#
        label = np.array(Image.open(gt_imgs[ind]).convert('L'))  
        
        # 如果圖像分割結(jié)果與標(biāo)簽的大小不一樣,這張圖片就不計(jì)算
        if len(label.flatten()) != len(pred.flatten()):  
            print(
                'Skipping: len(gt) = {:d}, len(pred) = {:d}, {:s}, {:s}'.format(
                    len(label.flatten()), len(pred.flatten()), gt_imgs[ind],
                    pred_imgs[ind]))
            continue

        #------------------------------------------------#
        #   對一張圖片計(jì)算21×21的hist矩陣,并累加
        #------------------------------------------------#
        a=label.flatten()
        a//=254
       
        b=pred.flatten()
        b//=254
        hist += fast_hist(a, b,num_classes)  
        # # 每計(jì)算10張就輸出一下目前已計(jì)算的圖片中所有類別平均的mIoU值
        # mIoUs   = per_class_iu(hist)
        # mPA     = per_class_PA(hist)
        # m_iou.append(100 * np.nanmean(mIoUs[1]))
        # m_pa.append(100 * np.nanmean(mPA[1]))
        # # if ind > 0 and ind % 10 == 0:  
        # #     print('{:d} / {:d}: mIou-{:0.2f}; mPA-{:0.2f}'.format(ind, len(gt_imgs),
        # #                                             100 * np.nanmean(mIoUs[1]),
        # #                                             100 * np.nanmean(mPA[1])))
    print(hist)
    mIoUs   = per_class_iu(hist)
    mPA     = per_class_PA(hist)
    print(mIoUs)

    # plt.figure()
    # x=np.arange(len(m_iou))
    # plt.plot(x,m_iou)
    # plt.plot(x,m_pa)
    # plt.grid(True)
    # y_major_locator=MultipleLocator(10)#把y軸的刻度間隔設(shè)置為10,并存在變量里
    # ax = plt.gca()
    # ax.yaxis.set_major_locator(y_major_locator)
    # ax.set_ylim(0,100)
    # plt.xlabel('Order')
    # plt.ylabel('mIOU & mPA')
    # plt.legend(['mIOU','mPA'],loc="upper right")

    # targ=os.path.join(pred_dir,os.path.pardir)
    

    # plt.savefig(os.path.join(targ, weight_name[:-3]+"_sin_miou.png"))

    return m_iou,m_pa,str(round(mIoUs[1] * 100, 2)),str(round(mPA[1] * 100, 2))

到了這里,關(guān)于語義分割混淆矩陣、 mIoU、mPA計(jì)算的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 圖像分割評價(jià)指標(biāo):Dice和MIoU

    圖像分割評價(jià)指標(biāo):Dice和MIoU

    Dice用來衡量預(yù)測結(jié)果pred和標(biāo)簽label的相似度,公式如下圖所示,即兩個(gè)集合的交集/并集。 注意:對于多分類的分割任務(wù),網(wǎng)絡(luò)的輸出結(jié)果是多通道的,使用Dice計(jì)算準(zhǔn)確度需要將標(biāo)簽轉(zhuǎn)換為多通道的one_hot形式。 如果需要計(jì)算 dice loss ,只需要 1- dice_acc 即可。 可以借助 torc

    2024年02月02日
    瀏覽(19)
  • 語義分割準(zhǔn)確率計(jì)算

    目錄 pytorch版 pytorch準(zhǔn)確率,miou: sklearn版

    2024年02月06日
    瀏覽(25)
  • 計(jì)算機(jī)視覺基礎(chǔ)(11)——語義分割和實(shí)例分割

    計(jì)算機(jī)視覺基礎(chǔ)(11)——語義分割和實(shí)例分割

    在這節(jié)課,我們將學(xué)習(xí) 語義分割和實(shí)例分割 。在語義分割中,我們需要重點(diǎn)掌握語義分割的 概念、常用數(shù)據(jù)集、評價(jià)指標(biāo)(IoU)以及經(jīng)典的語義分割方法(Deeplab系列) ;在實(shí)例分割中,需要知道實(shí)力分割可以近似看為“ 目標(biāo)檢測+語義分割 ”,需要知道 Mask R-CNN方法的計(jì)算

    2024年01月23日
    瀏覽(34)
  • 圖像分割與語義分割在計(jì)算機(jī)視覺中的應(yīng)用

    計(jì)算機(jī)視覺(Computer Vision)是人工智能領(lǐng)域的一個(gè)重要分支,它旨在讓計(jì)算機(jī)理解和解釋人類世界中的視覺信息。圖像分割(Image Segmentation)和語義分割(Semantic Segmentation)是計(jì)算機(jī)視覺中的兩個(gè)重要技術(shù),它們涉及將圖像中的不同部分分為不同的類別,以便計(jì)算機(jī)更好地理解圖像的

    2024年03月12日
    瀏覽(21)
  • 計(jì)算機(jī)視覺:語義分割理論及實(shí)戰(zhàn)

    計(jì)算機(jī)視覺:語義分割理論及實(shí)戰(zhàn)

    語義分割(Semantic Segmentation)是指將一張圖像分割成若干個(gè)區(qū)域,并對每個(gè)區(qū)域賦予語義標(biāo)簽的任務(wù)。它是計(jì)算機(jī)視覺中的一種重要技術(shù),被廣泛應(yīng)用于自動(dòng)駕駛、醫(yī)學(xué)圖像分析、地理信息系統(tǒng)等領(lǐng)域。 與傳統(tǒng)的圖像分割任務(wù)不同,語義分割不僅需要將圖像分割成若干個(gè)區(qū)域

    2024年02月08日
    瀏覽(23)
  • Python計(jì)算語義分割模型的評價(jià)指標(biāo)

    Python計(jì)算語義分割模型的評價(jià)指標(biāo)

    目錄 一、混淆矩陣 二、分類指標(biāo) 1、Accuracy(準(zhǔn)確率) 2、Precision(查準(zhǔn)率) 3、Recall (查全率) 4、F1-score? 三、語義分割的評價(jià)指標(biāo) 1、MPA(類別平均像素準(zhǔn)確率) 2、IoU(交并比) 3、MIoU(平均交并比) 4、CPA(類別像素準(zhǔn)確率) 5、PA(像素準(zhǔn)確率) 四、代碼實(shí)現(xiàn)(基于混淆矩陣)? 混淆

    2024年02月04日
    瀏覽(26)
  • 圖像分類 圖像分割的評價(jià)指標(biāo)(混淆矩陣 正確率 精準(zhǔn)率 召回率 F1分?jǐn)?shù) IOU dice系數(shù))

    圖像分類 圖像分割的評價(jià)指標(biāo)(混淆矩陣 正確率 精準(zhǔn)率 召回率 F1分?jǐn)?shù) IOU dice系數(shù))

    ?????????在圖像分類或者圖像分割中,為 評價(jià)模型的預(yù)測效果 ,在訓(xùn)練過程中通常需要比較預(yù)測值與真實(shí)標(biāo)簽值的差距,即誤差。 目錄 圖像分類過程的評價(jià)指標(biāo) 混淆矩陣 正確率/準(zhǔn)確率 精準(zhǔn)率 召回率 F1分?jǐn)?shù) 圖像分割過程的評價(jià)指標(biāo) 混淆矩陣 混淆矩陣的生成代碼 IO

    2024年01月22日
    瀏覽(34)
  • pytorch 計(jì)算混淆矩陣

    pytorch 計(jì)算混淆矩陣

    混淆矩陣是評估模型結(jié)果的一種指標(biāo) 用來判斷分類模型的好壞 ?預(yù)測對了 為對角線? 還可以通過矩陣的上下角發(fā)現(xiàn)哪些容易出錯(cuò) 從這個(gè) 矩陣出發(fā) 可以得到 acc !=?precision recall? 特異度? ? ?目標(biāo)檢測01筆記AP mAP recall precision是什么 查全率是什么 查準(zhǔn)率是什么 什么是準(zhǔn)確率

    2024年02月02日
    瀏覽(21)
  • 計(jì)算機(jī)視覺框架OpenMMLab(七):語義分割實(shí)戰(zhàn)

    計(jì)算機(jī)視覺框架OpenMMLab(七):語義分割實(shí)戰(zhàn)

    ????? 作者簡介: 大數(shù)據(jù)專業(yè)碩士在讀,CSDN人工智能領(lǐng)域博客專家,阿里云專家博主,專注大數(shù)據(jù)與人工智能知識分享。 公眾號: GoAI的學(xué)習(xí)小屋,免費(fèi)分享書籍、簡歷、導(dǎo)圖等資料,更有交流群分享AI和大數(shù)據(jù),加群方式公眾號回復(fù)“加群”或??點(diǎn)擊鏈接。 ?? 專欄推

    2024年02月02日
    瀏覽(29)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包