ilnehc96 / HKU-DASC7606-A1

HKU DASC 7606 Assignment 1 (Computer Vision), 2023-24 Spring
18 stars 18 forks source link

Question about understanding losses.py #2

Closed PengxinWang closed 7 months ago

PengxinWang commented 8 months ago

I'm confused by some code of losses.py in the 78th line. IoU = calc_iou(anchors[0, :, :], bbox_annotation[:, :4]) # num_anchors x num_annotations

  1. If I understand corrently, the first dimension of anchors represents different examples in the batch, and bbox_annotation is the jth example in the batch. Then does it make more sense to be IoU = calc_iou(anchors[j, :, :], bbox_annotation[:, :4]) # num_anchors x num_annotations?

  2. For the code of clac_iou, which is the part we need to complete, we're required to calculate the IoU between two boxes, here we are calculating IoU between num_anchors and num_annotations, so does a,b in the function calc_IoU are batches of boxes?

ilnehc96 commented 7 months ago
  1. Great question. Note that imgs in one batch use same anchors. You can debug the shape of anchors. It should be [1, xx, xx], instead of [batch size, xx, xx]. Find more details about how to generate anchors in anchors.py,
  2. Yes. a and b in calc_IoU are batches of boxes.