Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the iou method in yolo_tiny_net.py #67

Open
xadxxadx opened this issue Feb 15, 2019 · 2 comments
Open

the iou method in yolo_tiny_net.py #67

xadxxadx opened this issue Feb 15, 2019 · 2 comments

Comments

@xadxxadx
Copy link

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

@Jerryzhangzhao
Copy link

Jerryzhangzhao commented Feb 20, 2019

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)

@yuanliangxie
Copy link

the iou methed is wrong, buddy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants