当前位置:网站首页>Recorded target detection NMS (non maximum suppression)
Recorded target detection NMS (non maximum suppression)
2022-07-26 02:21:00 【NuerNuer】
NMS thought :
1. First, sort all boxes by confidence , Select the box with the highest confidence , Write it down as S
2. Remaining boxes and S do IOU Calculation , Greater than the set threshold threshold ( permanent 0.7) Others are suppressed , The most basic suppression method is to set the confidence of these boxes 0.
3. Continue to find the one with the highest score in the remaining boxes , repeat 1,2. To the box without repetition , Algorithm stop .
pytorch Realization ( quote :https://blog.csdn.net/KANG157/article/details/124649838):
For specific analysis, I gave comments in the code
def NMS(boxes,scores, thresholds):
x1 = boxes[:,0] # Top left x
y1 = boxes[:,1] # Top left y
x2 = boxes[:,2] # Lower right x
y2 = boxes[:,3] # Lower right y
areas = (x2-x1)*(y2-y1) # Calculate the area of each box , There is aeras in
_,order = scores.sort(0,descending=True) # Rank the scores of all boxes in descending order , return order Indexes
keep = []
while order.numel() > 0: # When order The number of elements is not 0
i = order[0] # Get the index with the highest score and assign it to i, Remember this box as S
keep.append(i) # Add in keep Set
if order.numel() == 1: # If there is only one box , Then the algorithm ends
break
xx1 = x1[order[1:]].clamp(min=x1[i]) # adopt clamp function , Check the remaining boxes and S The upper left point of the intersection x value
yy1 = y1[order[1:]].clamp(min=y1[i]) # adopt clamp function , Check the remaining boxes and S The upper left point of the intersection y value
xx2 = x2[order[1:]].clamp(max=x2[i]) # adopt clamp function , Check the remaining boxes and S The lower right point of the intersection x value
yy2 = y2[order[1:]].clamp(max=y2[i]) # adopt clamp function , Check the remaining boxes and S The upper left point of the intersection x value
w = (xx2-xx1).clamp(min=0) # Will intersect width Negative values are limited to 0, The goal is a box without intersection , The intersection part is set to 0
h = (yy2-yy1).clamp(min=0) # Will intersect height Negative values are limited to 0, ditto
inter = w*h # Calculate the intersection area
ovr = inter/(areas[i] + areas[order[1:]] - inter) # Calculation iou
ids = (ovr<=thresholds).nonzero().squeeze() # Get all iou The index of the box whose value is less than the threshold
if ids.numel() == 0: # When does not exist and the current box iou When the value is less than the threshold box , Code end
break
order = order[ids+1] # Pay attention to the addition here 1, because ids The calculation is in addition to the first box , Make a recovery to order Step back 1 individual , So add 1
return torch.LongTensor(keep)Function analysis :
torch.sort(input, dim=0, descending=False)
dim: Sort dimension
descending: Descending or not
return:1. An ordered array
2. The corresponding index torch.clamp(input, min=a, max=b)
usage: take input Data is limited to [a,b] In closed interval
principle :
input[i] = a, if input[i] <= a
= input[i] if input[i] > a and input[i] < b
= b if input[i] >= btorch.nonzero(input)
return: input Central Africa 0 Index of elements 边栏推荐
- EAM系统能帮助企业做什么?
- Digital warehouse: on the construction practice of digital warehouse in banking industry
- Niuke net question brushing training (I)
- Design and driver transplantation of matrix keyboard circuit of Ti am335x industrial control module
- I.MX6UL核心模块使用连载-eMMC读写测试 (四)
- Monitoring of debezium synchronization debezium
- 1. Mx6ul core module use serial -rs485 test (x)
- 必会面试题:1.浅拷贝和深拷贝_深拷贝
- How to choose cloud note tool? What can I do with cloud notes?
- Prometheus + redis exporter + grafana monitor redis service
猜你喜欢

Ti am335x industrial control module uses the Debian system of beaglebone (BBB)

Wechat applet decryption and unpacking to obtain source code tutorial

1. Mx6ul core module use serial TF card read / write test (V)

1. Mx6ul core module uses serial NAND FLASH read / write test (III)

主键B+ Tree,二级索引B+ Tree及对应的查询过程分析

由一个数据增量处理问题看到技术人员的意识差距

Prometheus+blackbox exporter+grafana monitoring server port and URL address

Are you still using ==0 null equal to judge null values? How much do you know about isempty and isblank

TCP三次握手四次挥手

1. Mx6ul core module serial USB interface test (VI)
随机推荐
1. Mx6ul core module uses serial NAND FLASH read / write test (III)
Overview of pytoch's API
Adruino 基础实验学习(一)
[xxl-job] xxl-job learning
National standard gb28181 protocol video platform easygbs message pop-up mode optimization
Niuke net question brushing training (I)
17.反转链表
Basic usage of set, map, DOM classlist in ES6
一款可插拔的AM335X工控模块板载wifi模块
3. Upload the avatar to qiniu cloud and display it
Design and driver transplantation of matrix keyboard circuit of Ti am335x industrial control module
1. Mx6ul core module serial WiFi test (VIII)
How to choose cloud note tool? What can I do with cloud notes?
必会面试题:1.浅拷贝和深拷贝_深拷贝
Quick start of adding, deleting, modifying and checking business
Li Kou 148: sorting linked list
Pytorch的API总览
19_请求表单与文件
Be careful about bitmap, the "memory Assassin"~
prometheus+process-exporter+grafana 监控进程的资源使用