tensorflow-yolo icon indicating copy to clipboard operation
tensorflow-yolo copied to clipboard

the iou method in yolo_tiny_net.py

Open xadxxadx opened this issue 6 years ago • 2 comments

at line 115 : boxes1 = tf.transpose(boxes1, [1, 2, 3, 0])

the boxes1 data format transform from [cx, cy, w, h] to [x1, y1, x2, y2] yet. why there is line 115 convet format to [y1, x2, y2, x1] ????

I don't understand

thanks

xadxxadx avatar Feb 15 '19 08:02 xadxxadx

The result of line 115 : boxes1 = tf.transpose(boxes1, [1, 2, 3, 0]) is not with format [y1, x2, y2, x1]. Actually, boxes1 is a 4-D tensor, the tf.transpose operation change the order of dimensions from [0,1,2,3] to [1,2,3,0]. To understand why there is a transpose operation, we have to take line 114 and 115 together into consideration.

114: boxes1 = tf.stack([boxes1[:, :, :, 0] - boxes1[:, :, :, 2] / 2, boxes1[:, :, :, 1] - boxes1[:, :, :, 3] / 2,boxes1[:, :, :, 0] 
                           + boxes1[:, :, :, 2] / 2, boxes1[:, :, :, 1] + boxes1[:, :, :, 3] / 2])
115: boxes1 = tf.transpose(boxes1, [1, 2, 3, 0])

In line 114, the coordinate 'data format' was transformed from [center_x,center_y,w,h] to [x_min,y_min,x_max,y_max] and then stack the four tensor to be one with the default parameter 'axis=0', thus the result tensorboxes1 is no longer has the same shape before tf.stack() operation. So the transpose operation is aim to transform the shape of tensor boxes1 to original.

Actually, line 114 and 115 can be written as a single line:

boxes1 = tf.stack([boxes1[:, :, :, 0] - boxes1[:, :, :, 2] / 2, boxes1[:, :, :, 1] - boxes1[:, :, :, 3] / 2,boxes1[:, :, :, 0] 
                           + boxes1[:, :, :, 2] / 2, boxes1[:, :, :, 1] + boxes1[:, :, :, 3] / 2], axis=3)

Jerryzhangzhao avatar Feb 20 '19 14:02 Jerryzhangzhao

the iou methed is wrong, buddy!

yuanliangxie avatar Aug 23 '19 12:08 yuanliangxie