open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.02k stars 9.36k forks source link

[Feature] omit setting gt labels to be zeros in RPN Head #9182

Open ZwwWayne opened 1 year ago

ZwwWayne commented 1 year ago

What's the feature?

In RPN head, there are some legacy codes do the following:

# set cat_id of gt_labels to 0 in RPN
            for data_sample in rpn_data_samples:
                data_sample.gt_instances.labels = \
                    torch.zeros_like(data_sample.gt_instances.labels)

However, we can keep the assignment progress of RPN the same as that in RCNN, and only re-map the learning targets of labels/logits to zero just before the loss calculation. This unifies and simplifies the code and assignment.

Any other context?

No response

BIGWangYuDong commented 1 year ago

Does it mean we need to add a cfg flag in rpn_cfg to handle this case? This code logic is going to handle replacing RPN to other single-stage head without any codes adding.