trying to understand how do we compute the overlap?
in the bbox_transform when we compute overlap i have problems understanding the steps :(
what is
iw = (torch.min(boxes[:,:,:,2], query_boxes[:,:,:,2]) - torch.max(boxes[:,:,:,0], query_boxes[:,:,:,0]) + 1)
iw[iw < 0] = 0,
also we have
ua = anchors_area + gt_boxes_area - (iw * ih)
and
ua = anchors_area + gt_boxes_area - (iw * ih)
overlaps = iw * ih / ua
Can anyone please help me understand what we are doing in this function?
Also the part after that which is for filling:
# mask the overlap here.
overlaps.masked_fill_(gt_area_zero.view(batch_size, 1, K).expand(batch_size, N, K), 0)
overlaps.masked_fill_(anchors_area_zero.view(batch_size, N, 1).expand(batch_size, N, K), -1)
I appreciate if anyone can explain these :)
For the first part
iw = (torch.min(boxes[:,:,:,2], query_boxes[:,:,:,2]) - torch.max(boxes[:,:,:,0], query_boxes[:,:,:,0]) + 1)
You are coumputing intersection area's width. Which is min(anchor.x2 - gt_box.x2) - max(anchor.x1 - gt_box.x1) You can draw two overlaped box with x1,y1 as left uper corner and x2,y2 as right lower corner, and you should able to find out this is easy way to compute intersection's width and height
For iw[iw < 0] = 0
I think this is prevent some error. Width should never be negative
ua = anchors_area + gt_boxes_area - (iw * ih)
This is to comput union area between ground truth and anchor
I need to look more to see what masked_fill do.
@dechunwang can you explain how masking is being performed? I am confused why the two different areas are being masked differently , one as 0 and other as -1