当前位置:网站首页>NMS reduction box
NMS reduction box
2022-06-25 20:06:00 【Orange cedar】
import numpy as np
def NMS(nums, threshold):
x1 = nums[:, 0]
y1 = nums[:, 1]
x2 = nums[:, 2]
y2 = nums[:, 3]
area = (x2 - x1) * (y2 - y1)
score = nums[:, 4]
score = np.argsort(score)[::-1]
# The function is to x The elements in are arranged from small to large , Extract the corresponding index( Indexes ), Then output to argsort()
keep = []
while score.size > 0:
#print("score=",score)
keep.append(score[0])
# Calculation times greater than score All the frames with the largest score Of IOU
xx1 = np.maximum(x1[score[0]], x1[score[1:]]) # Be careful : Here is an iterator for
yy1 = np.maximum(y1[score[0]], y1[score[1:]])
xx2 = np.minimum(x2[score[0]], x2[score[1:]])
yy2 = np.minimum(y2[score[0]], y2[score[1:]])
w = np.maximum(0.0, xx2 - xx1)
h = np.maximum(0.0, yy2 - yy1)
# IOU
overlap = w * h
iou = overlap/(area[score[0]] + area[score[1:]] - overlap)
# print("iou=",iou)
iou_low = np.where(iou <= threshold)[0] # Returns all and maximum score Compared with <threshold The subscript
# print(" Find the rectangle index whose overlap is not higher than the threshold :",iou_low)
score = score[iou_low + 1]
return keep
边栏推荐
- Arduino read temperature
- The functions in the applet page are better than those in app JS first execution solution
- 在打新债开户证券安全吗?低佣金靠谱吗
- A necessary programming assistant for programmers! Smartcoder helps you easily integrate HMS core
- JS mobile phone and computer open different websites
- 2.15(Multiple of 3 Or 5)
- C language PTA -- continuity factor
- <C>. function
- Appearance of object attributes
- Redis is a loser. If you don't understand the usage specification, you will spoil it
猜你喜欢

Remember to deploy selenium crawler on the server

Jsonp non homologous interaction (click trigger)

<C>. Rolling phase division

H5 application conversion fast application

Bindgetuserinfo will not pop up

Vulnhub range the planes: mercury

String since I can perform performance tuning, I can call an expert directly

CG kit explore high performance rendering on mobile terminal

Automatic fitting when the applet reaches the top

II Traits (extractors)
随机推荐
Curtain down and departure
Is it safe to open an online account for new bonds? What should be paid attention to
PAT B1081
8. iterators and generators
Jsonp function encapsulation
Use of serialize() and serializearray() methods for form data serialization
rmi-registry-bind-deserialization
PAT B1063
Redis core article: the secret that can only be broken quickly
Jsonp non homologous interaction (click trigger)
Simple native JS tab bar switching
The error log of vscode connecting to the server shows the problem of "insufficient permission". Directly use root to connect
2.4 finding the sum of the first n terms of the interleaved sequence
在打新债开户证券安全吗?低佣金靠谱吗
Remember to deploy selenium crawler on the server
Browser performance optimization (19)
<C>. Figure guessing game
Life cycle function of composite API
PAT B1057
PAT B1096