facebookresearch / unbiased-teacher

PyTorch code for ICLR 2021 paper Unbiased Teacher for Semi-Supervised Object Detection
https://arxiv.org/abs/2102.09480
MIT License
415 stars 83 forks source link

How to perform NMS before generating pseudo labels? #20

Closed SkeletonOne closed 3 years ago

SkeletonOne commented 3 years ago

Hi! Thanks for your work and I am wondering how the NMS can be performed before generating the pseudo label. I conjecture that it might in the function https://github.com/facebookresearch/unbiased-teacher/blob/ba543ed2b87446c79eaf41f93320de246c8eedc2/ubteacher/engine/trainer.py#L319 or https://github.com/facebookresearch/unbiased-teacher/blob/ba543ed2b87446c79eaf41f93320de246c8eedc2/ubteacher/engine/trainer.py#L354 but I cannot find it. Could you please provide some instructions or is there something I am missing?

ycliu93 commented 3 years ago

The output of this line is the boxes after NMS, so we only do confidence thresholding (i.e., select the pseudo-boxes which box score are higher than a threshold). https://github.com/facebookresearch/unbiased-teacher/blob/ba543ed2b87446c79eaf41f93320de246c8eedc2/ubteacher/engine/trainer.py#L431

For the code of NMS, you could check the inference function of this class, which uses its parent class's function.
https://github.com/facebookresearch/unbiased-teacher/blob/ba543ed2b87446c79eaf41f93320de246c8eedc2/ubteacher/modeling/roi_heads/fast_rcnn.py#L12

Details of its parent class in detectron2: https://github.com/facebookresearch/detectron2/blob/d57c38ce8b536472fdab131ece19a745204edbd6/detectron2/modeling/roi_heads/fast_rcnn.py#L118

and NMS function https://github.com/facebookresearch/detectron2/blob/d57c38ce8b536472fdab131ece19a745204edbd6/detectron2/modeling/roi_heads/fast_rcnn.py#L118

Sorry for doing NMS in this implicit way, we just try to make it align with the original implementation of detectron2. Let me know if you have any other problems. Thanks!

SkeletonOne commented 3 years ago

@ycliu93 Thanks for your reply, clear enough! :)

SkeletonOne commented 3 years ago

@ycliu93 Another little question: Does the backbone (ResNet) of the student needs update during Mutual Learning Stage, or only the RPN and ROI heads? And what about the backbone of the teacher during EMA? Thanks!

ycliu93 commented 3 years ago

In the mutual learning stage:

The Student weights including the feature backbone, the RPN, and the ROIhead are updated with supervised loss and unsupervised loss.

The Teacher weights including the feature backbone, the RPN, and the ROIhead are updated via EMA.

Thanks!

SkeletonOne commented 3 years ago

Sincerely appreciate your detailed reply!