broadinstitute / keras-rcnn

Keras package for region-based convolutional neural networks (RCNNs)
Other
553 stars 223 forks source link

gt Overlapping indices #30

Closed jhung0 closed 7 years ago

jhung0 commented 7 years ago

Why is this line necessary/what is it for? Isn't gt_argmax_overlaps_inds defined before this line? https://github.com/broadinstitute/keras-rcnn/blob/master/keras_rcnn/layers/object_detection/_anchor.py#L237

JihongJu commented 7 years ago

@jhung0

# overlaps is a matrix of shape (n_pred, n_true)
overlaps = keras_rcnn.backend.bbox_overlaps(y_pred, y_true[:, :4])

# 0. Find the pred index with the maximum overlap for each gt box (e.g. [1, 2, 1])
gt_argmax_overlaps_inds = overlaps.argmax(axis=0)

# 1. Find the maximum overlap for each gt box
gt_max_overlaps = overlaps[gt_argmax_overlaps_inds, numpy.arange(overlaps.shape[1])]

# 2. For each pred, find how many gt boxes it has maximum overlap (e.g. [1, 1, 2])
# (Don't know if this is your expected return or 0. is)
gt_argmax_overlaps_inds = numpy.where(overlaps == gt_max_overlaps)[0]

And I think if 2. is the expected return,

gt_argmax_overlaps_inds = numpy.sort(gt_argmax_overlaps_inds)

would do the trick.