rpn:region proposal network
IoU:Intersection-over-Union,交集并集之比
GT:ground truth,GT boxes (x1, y1, x2, y2, label),左上的坐标 和 右下的坐标 + label
im:image
ROI:region of interest
bbox:bounding-box
regression:和one hot的classification其实区别不大,只是target是(可能为0和1以及)其他数字
anchor:一个box,通过从上一个卷积层的结果 滑动得到很多个,每个要和 GT的box 计算bbox_overlap
bbox_overlap:貌似就是IoU,源码如下

def bbox_overlaps(
np.ndarray[DTYPE_t, ndim=2] boxes, #anchor的box
np.ndarray[DTYPE_t, ndim=2] query_boxes): #GT的box
"""
Parameters
----------
boxes: (N, 4) ndarray of float #(x1, y1, x2, y2)
query_boxes: (K, 4) ndarray of float #(x1, y1, x2, y2)
Returns
-------
overlaps: (N, K) ndarray of overlap between boxes and query_boxes
"""
cdef unsigned int N = boxes.shape[0] #个数
cdef unsigned int K = query_boxes.shape[0] #个数
cdef np.ndarray[DTYPE_t, ndim=2] overlaps = np.zeros((N, K), dtype=DTYPE)
cdef DTYPE_t iw, ih, box_area
cdef DTYPE_t ua
cdef unsigned int k, n
for k in range(K):
box_area = ( #query_boxes的面积
(query_boxes[k, 2] - query_boxes[k, 0] + 1) *
(query_boxes[k, 3] - query_boxes[k, 1] + 1)
)
for n in range(N):
iw = (
min(boxes[n, 2], query_boxes[k, 2]) -
max(boxes[n, 0], query_boxes[k, 0]) + 1
)
if iw > 0: #两个box的w有交集
ih = (
min(boxes[n, 3], query_boxes[k, 3]) -
max(boxes[n, 1], query_boxes[k, 1]) + 1
)
if ih > 0: #两个box的h有交集
ua = float(
(boxes[n, 2] - boxes[n, 0] + 1) *
(boxes[n, 3] - boxes[n, 1] + 1) +
box_area - iw * ih
)
overlaps[n, k] = iw * ih / ua #交集面积 除以 并集面积
return