生活随笔
收集整理的這篇文章主要介紹了
【算法】非极大值抑制原理、流程和代码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼如下:
import numpy
as np
def py_cpu_nms(dets
, thresh
):"""Pure Python NMS baseline."""x1
= dets
[:, 0] y1
= dets
[:, 1] x2
= dets
[:, 2] y2
= dets
[:, 3] scores
= dets
[:, 4] areas
= (x2
- x1
+ 1) * (y2
- y1
+ 1) order
= scores
.argsort
()[::-1] keep
= [] while order
.size
> 0:i
= order
[0] keep
.append
(i
) xx1
= np
.maximum
(x1
[i
], x1
[order
[1:]]) yy1
= np
.maximum
(y1
[i
], y1
[order
[1:]])xx2
= np
.minimum
(x2
[i
], x2
[order
[1:]])yy2
= np
.minimum
(y2
[i
], y2
[order
[1:]])w
= np
.maximum
(0.0, xx2
- xx1
+ 1)h
= np
.maximum
(0.0, yy2
- yy1
+ 1)inter
= w
* hovr
= inter
/ (areas
[i
] + areas
[order
[1:]] - inter
) inds
= np
.where
(ovr
<= thresh
)[0] order
= order
[inds
+ 1] return keep
if __name__
== '__main__':dets
= np
.array
([[100,120,170,200,0.98],[20,40,80,90,0.99],[20,38,82,88,0.96],[200,380,282,488,0.9],[19,38,75,91, 0.8]])py_cpu_nms
(dets
, 0.5)
參考資料:https://zhuanlan.zhihu.com/p/49481833
猜你喜歡:👇🏻
?【算法】ROI Align 原理
?【算法】anchor free 和 anchor based 目標檢測模型
?【算法】交叉熵損失和KL散度
總結
以上是生活随笔為你收集整理的【算法】非极大值抑制原理、流程和代码的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。