理解目標(biāo)檢測(cè)4:評(píng)價(jià)指標(biāo)IoU

《理解目標(biāo)檢測(cè)3:評(píng)價(jià)指標(biāo)F1 Score》中提到的F1 Score和Accuracy,主要用于評(píng)價(jià)分類(lèi)算法的好壞,對(duì)于多類(lèi)別目標(biāo)檢測(cè)算法,需要使用評(píng)價(jià)指標(biāo)mAP和IoU。
??IoU用于輔助指出哪個(gè)預(yù)測(cè)框是正確的(Positive)?下圖中,黃色框是標(biāo)注框(Ground Truth),紅色、藍(lán)色和綠色框是三個(gè)不同的預(yù)測(cè)框,那么哪個(gè)預(yù)測(cè)框是正確的呢?直觀感覺(jué)是,預(yù)測(cè)框與標(biāo)注框重疊部分越多,預(yù)測(cè)框越準(zhǔn)確。

預(yù)測(cè)框1-2-3

定義:IoU = 標(biāo)記框與檢測(cè)框的交集除以并集,Python代碼實(shí)現(xiàn)如下:
def bb_intersection_over_union(boxA, boxB):
    # determine the (x, y)-coordinates of the intersection rectangle
    xA = max(boxA[0], boxB[0])
    yA = max(boxA[1], boxB[1])
    xB = min(boxA[2], boxB[2])
    yB = min(boxA[3], boxB[3])
    # compute the area of intersection rectangle
    interArea = max(0, xB - xA + 1) * max(0, yB - yA + 1)
    # compute the area of both the prediction and ground-truth
    # rectangles
    boxAArea = (boxA[2] - boxA[0] + 1) * (boxA[3] - boxA[1] + 1)
    boxBArea = (boxB[2] - boxB[0] + 1) * (boxB[3] - boxB[1] + 1)
    # compute the intersection over union by taking the intersection
    # area and dividing it by the sum of prediction + ground-truth
    # areas - the interesection area
    iou = interArea / float(boxAArea + boxBArea - interArea)
    # return the intersection over union value
    return iou
IoU定義

我們可以給IoU設(shè)置一個(gè)門(mén)限,例如:IoU = 0.5,這時(shí),可以得到下面的結(jié)果。IoU也可以設(shè)為0.75,這樣對(duì)算法的要求就更高了。

IoU=0.5,TP與FP

Confidence score: 由神經(jīng)網(wǎng)絡(luò)分類(lèi)器(NN classifier)算出來(lái),展現(xiàn)邊界框(bbox)中,包含目標(biāo)物體的信心程度(取值范圍:0~1)。Confidence score用于丟棄包含有相同物體的,沒(méi)有達(dá)到confidence threshold的,重復(fù)多余的檢測(cè)框。confidence scores reflect how confident the model is that the box contains an object. If no object exists in that cell, the confidence scores should be zero. 參考《 如何計(jì)算神經(jīng)網(wǎng)絡(luò)預(yù)測(cè)的置信度分?jǐn)?shù)》《計(jì)算confidence interval

Confidence scoreIoU 共同用于計(jì)算FP和TP,范例代碼如下:

for each detection that has a confidence score > threshold:

  among the ground-truths, choose one that belongs to the same class and has the highest IoU with the detection
  
  if no ground-truth can be chosen or IoU < threshold (e.g., 0.5):
    the detection is a false positive
  else:
    the detection is a true positive

參考:https://github.com/rafaelpadilla/Object-Detection-Metrics

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容