日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

深度学习中IU、IoU(Intersection over Union)的概念理解以及python程序实现

發布時間:2025/7/25 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 深度学习中IU、IoU(Intersection over Union)的概念理解以及python程序实现 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

from: 深度學習中IU、IoU(Intersection over Union)的概念理解以及python程序實現
IoU(Intersection over Union)

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 就可以被認為一個不錯的結果了。

python程序實現

具體實現過程請移步:https://www.pyimagesearch.com/2016/11/07/intersection-over-union-iou-for-object-detection/

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就是三個物體分別準確度加起來的平均值。
參考資料:

1、https://www.pyimagesearch.com/2016/11/07/intersection-over-union-iou-for-object-detection/
2、https://stackoverflow.com/questions/25349178/calculating-percentage-of-bounding-box-overlap-for-image-detector-evaluation/42874377#42874377
3、https://stackoverflow.com/questions/25349178/calculating-percentage-of-bounding-box-overlap-for-image-detector-evaluation/42874377#42874377

Part II

AP、MAP、IOU


一張圖像的C類的P=圖像正確預測(True Positives)的數量 除以 在圖像中這一類的總目標數量。
1 AP

C類的平均精度=在驗證集上所有的圖像對于類C的精度值的和 除以 有類C這個目標的所有圖像的數量。
2 MAP

MAP = 所有類別的平均精度求和 除以 所有的類別 。
3 IOU

loU(交并比)是模型所預測的檢測框和真實(ground truth)的檢測框的交集和并集之間的比例。

總結

以上是生活随笔為你收集整理的深度学习中IU、IoU(Intersection over Union)的概念理解以及python程序实现的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。