分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
RCNN 和微软提出的 SPP_net 等著名的目标检测模型,在算法具体的实施过程中,一般都会用到 non-maximum suppress(非最大值抑制,抑制即忽略, 也即忽略那些值(IoU)高于提供的阈值的) 的机制。
引入 non-maximum suppression 的目的在于:根据事先提供的 score 向量,以及 regions(由不同的 bounding boxes,矩形窗口左上和右下点的坐标构成) 的坐标信息,从中筛选出置信度较高的 bounding boxes。
其基本操作流程如下:
- 首先,计算每一个 bounding box 的面积:
- (x1, y1) ⇒ 左上点的坐标,(x2, y2) ⇒ 右下点的坐标;
- (x2-x1+1)x(y2-y1+1)
- 根据 scores 进行排序(一般从小到大),将 score 最大的bounding box置于队列,接下来计算其余 bounding box 与当前 score 最大的 bounding box 的 IoU,抑制(忽略也即去除)IoU大于设定阈值的 bounding box;
- 重复以上过程,直至候选 bounding boxes 为空;
function picked = nms(boxes, overlap_thresh)% boxes[:, 1:4] 存储着 regions 信息,boxes[:, 5] 存储的则是 scores 向量if isempty(boxes) picked = []; return;endx1 = boxes[:, 1];y1 = boxes[:, 2]; % (x1, y1) ⇒ bounding boxes 左上点坐标的集合x2 = boxes[:, 3];y2 = boxes[:, 4]; % (x2, y2) ⇒ bounding boxes 右下点坐标的集合s = boxes[:, 5]; % scores 向量areas = (x2-x1+1).*(y2-y1+1); % 各个 bounding boxes 的面积[vals, idx] = sort(s); % 默认从小到大排序while ~isempty(idx) last = length(idx); i = idx(last); picked = [picked, i]; xx1 = max(x1(i), x1(1:last-1)); yy1 = max(y1(i), y1(1:last-1)); xx2 = min(x2(i), x2(1:last-1)); yy2 = min(y2(i), y2(1:last-1)); h = max(0, yy2-yy1+1); w = max(0, xx2-xx1+1); inter = w .* h; iou = inter ./ (areas(i) + areas(1:last-1)-inter); I = I(iou <= overlap_thresh);endend
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
给我老师的人工智能教程打call!http://blog.youkuaiyun.com/jiangjunshow
