語義分割 目標檢測 IOU計算相關

2021-08-22 03:15:15 字數 2203 閱讀 6498

intersection over union是一種測量在特定資料集中檢測相應物體準確度的乙個標準。我們可以在很多物體檢測挑戰中,例如pascal voc challenge中看多很多使用該標準的做法。

通常我們在 hog + linear svm object detectors 和 convolutional neural network detectors (r-cnn, faster r-cnn, yolo, etc.)中使用該方法檢測其效能。注意,這個測量方法和你在任務中使用的物體檢測演算法沒有關係。

iou是乙個簡單的測量標準,只要是在輸出中得出乙個**範圍(bounding boxex)的任務都可以用iou來進行測量。為了可以使iou用於測量任意大小形狀的物體檢測,我們需要: 

1、 ground-truth bounding boxes(人為在訓練集影象中標出要檢測物體的大概範圍); 

2、我們的演算法得出的結果範圍。

也就是說,這個標準用於測量真實和**之間的相關度,相關度越高,該值越高。

如下圖:

下圖展示了ground-truth和predicted的結果,綠色標線是人為標記的正確結果,紅色標線是演算法**出來的結果,iou要做的就是在這兩個結果中測量演算法的準確度。

如上圖,很簡單,iou相當於兩個區域重疊的部分除以兩個區域的集合部分得出的結果。 

一般來說,這個score > 0.5 就可以被認為乙個不錯的結果了。

具體實現過程請移步:

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 = (xb - xa + 1) * (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在fcn中稱為iu,初看fully convolutional networks for semantic segmentation**,其中的iu概念沒有能理解,其實那裡的iu也就是iou,檢測物體輪廓不一定非得是方框,也可以是沿著物體的邊線:

在實際的任務中,根據不同的任務要求來寫不同具體實現的檢測方法,但說白了其實都是iou或者iu。 

另外mean iu指的是不同類別識別準確度的平均值,比如一幅圖中要識別三個物體,mean iu就是三個物體分別準確度加起來的平均值。

目標檢測IOU計算

iou是交並比 intersection over union 是目標檢測中使用的乙個概念是產生的候選框 candidate bound 與原標記框 ground truth bound 的交疊率,即它們的交集與並集的比值。最理想情況是完全重疊,即比值為1。在多目標跟蹤中,用來判別跟蹤框和目標檢測框...

目標檢測 IoU 計算

我們先考慮一維的情況 令 a x 1,x 2 b y 1,y 2 若想要 a 與 b 有交集,需要滿足如下情況 簡言之,要保證 a 和 b 的最大值中最小的那個減去它們中的最小值中最大的那個即可獲得公共部分,實現如下 class anchor def init self,base size 16 s...

目標檢測中IoU計算

1.含義 iou即交並比 intersection over union 是真實的目標框ground truth與演算法 出來的目標框prediction之間差距的衡量指標。計算公式 iou a b a b 一般來說,iou值越大,說明 的越準確,通常取0.5作為閾值。2.python程式實現 de...