Yolo V3理解bbox和label的关系

假如一个bbox坐标为:[35 220 62 293 3]

第一步:将bbox转换为中心坐标和宽高形式(3种缩放比例进行缩放)

那么onehot:[0 0 0 1 0 0 0 0 0 0 ........],当然还可以平滑

计算bbox的中心坐标和宽高(35+62)/2 = 48.5   (220+293)/2=256.5  宽高为62-35 = 27  293-220=73

所以bbox的宽高中心坐标为(48.5 256.5 27 73)

然后根据缩放比例(8 16 32)进行缩放

缩放后的3组坐标为[[6.0625 32.0625 3.375 9.125][3.03 16.03 1.68 4.56][1.51 8.01 0.84 2.28]]

第二步:anchors中心和宽高获取

anchors的中心坐标和宽高总共3组每个缩放比例为8 :[[6.5 32.5 1.25 1.625][6.5 32.5 2 3.75][6.5 32.5 4.125 2.875]]

                 缩放比例为16:[[3.5 16.5 1.875 3.8125][3.5 16.5 3.875 2.8125][3.5 16.5 3.6875 7.4375]]

                 缩放比例为32:[[1.5 8.5 3.625 2.8125][1.5 8.5 4.875 6.1875][1.5 8.5 11.65625 10.1875]]

其中中心坐标为bbox的取整坐标加0.5,宽高坐标为kmeans聚类出来的

然后bbox的3组坐标分别和anchors的3组坐标计算iou

3组不同比例缩放的bbox对应3组anchors找到iou>0.3的并将网格的左上角坐标标记下来。

label格式为[np.zeros((train_output_sizes[i], train_output_sizes[i], anchor_per_scale,5 + num_classes)) for i in range(3)]

那么label i= [1,2,3]代表3种尺度:

label[i][yind, xind, iou_mask, :] = 0
label[i][yind, xind, iou_mask, 0:4] = bbox_xywh
label[i][yind, xind, iou_mask, 4:5] = 1.0
label[i][yind, xind, iou_mask, 5:] = smooth_onehot
posted @ 2020-01-10 14:58  奥布莱恩  阅读(1944)  评论(0编辑  收藏  举报