facebookresearch / unbiased-teacher

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

Change two stages to one stage #35

Open Jackson-zhao97 opened 2 years ago

Jackson-zhao97 commented 2 years ago

I want to use retinanet to change the two stages in the network, how can I do it based on detectron2?

ycliu93 commented 2 years ago

This repo does not support a one-stage Detector (such as RetinaNet) yet. Detectron2 does support RetinaNet, and I could give you some suggestions to change the backbone.

  1. You should keep the Unbiased Teacher Trainer.

  2. And follow the Detectron2 RetinaNet https://github.com/facebookresearch/detectron2/blob/master/configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml

and change these lines in the config file https://github.com/facebookresearch/unbiased-teacher/blob/6977c6f77c812fae4064dc1b3865658c2ed247b1/configs/coco_supervision/faster_rcnn_R_50_FPN_sup05_run1.yaml#L1-L15

  1. you also need to change the meta_arch of RetinaNet and produce the pseudo-labels. https://github.com/facebookresearch/detectron2/blob/master/detectron2/modeling/meta_arch/retinanet.py

  2. Tune the hyper-parameters for pseudo-labeling threshold and unsupervised loss weight, as the output of RetinaNet is sigmoid rather than softmax.

I know someone has used our Unbiased Teacher and successfully adapt to RetinaNet (and also improve against the supervised only significantly), so don't worry about whether the unbiased teacher can be used on RetinaNet.

luogen1996 commented 2 years ago

I want to use retinanet to change the two stages in the network, how can I do it based on detectron2?

Hi, i'm also trying to implement the one-stage ubteacher. If you have any experimental progress, i‘d like to disscuss with you.

Jackson-zhao97 commented 2 years ago

This repo does not support a one-stage Detector (such as RetinaNet) yet. Detectron2 does support RetinaNet, and I could give you some suggestions to change the backbone.

  1. You should keep the Unbiased Teacher Trainer.
  2. And follow the Detectron2 RetinaNet https://github.com/facebookresearch/detectron2/blob/master/configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml

and change these lines in the config file https://github.com/facebookresearch/unbiased-teacher/blob/6977c6f77c812fae4064dc1b3865658c2ed247b1/configs/coco_supervision/faster_rcnn_R_50_FPN_sup05_run1.yaml#L1-L15

  1. you also need to change the meta_arch of RetinaNet and produce the pseudo-labels. https://github.com/facebookresearch/detectron2/blob/master/detectron2/modeling/meta_arch/retinanet.py
  2. Tune the hyper-parameters for pseudo-labeling threshold and unsupervised loss weight, as the output of RetinaNet is sigmoid rather than softmax.

I know someone has used our Unbiased Teacher and successfully adapt to RetinaNet (and also improve against the supervised only significantly), so don't worry about whether the unbiased teacher can be used on RetinaNet.

Thank you very much for your suggestions! Now I have used mmdetection to change the unbiased teacher to one stage. But there is still a big gap between my experimental mAP and the experimental one. For example, when I tried to use 10% coco dataset as supervised data, in the burn in stage (fully supervised training), I only got 0.14 mAP, which was 9% lower than the result of the paper. After the semi-supervised learning, I only got a mAP of 0.19, which is 12% lower than the result of the paper.

Some of my hyper parameters are set as follows: imgs_per_gpu = 2 # set bacth_size=2, for me larger batch_size will lead to runtime error lr = 0.01 * (imgs_per_gpu / 32) # I have only one gpu lr_config = CosineAnnealing optimizer = SGD Unsuper_weight = 2.0 # unsupervised loss weight threshold = 0.5 # pseudo-labeling threshold

I also tried it on the VOC data set because it takes less time to train. I have observed the mAP of different learning rates in burn in stage, and the highest(35:42) is also 7% lower than the result in the paper. Is it because the result of the one-stage is lower than that of the two-stages?

Jackson-zhao97 commented 2 years ago

@Jackson-zhao97 Hello, I am also trying to replace the model now, may I communicate with you? My email is qianli_1209@163.com, looking forward to your reply.

Hi, I have reproduced this paper with mmdetection, and replaced the two-stages with one stage. There may be some problems, and I am experimenting.

darkhan-s commented 2 years ago

@Jackson-zhao97 Hello, I am also trying to replace the model now, may I communicate with you? My email is qianli_1209@163.com, looking forward to your reply.

Hi, I have reproduced this paper with mmdetection, and replaced the two-stages with one stage. There may be some problems, and I am experimenting.

Hi @Jackson-zhao97 and @luogen1996 would it be possible to take a look at the paper or the codebase?

sisrfeng commented 2 years ago

Any update? Thx

Jackson-zhao97 commented 2 years ago

Hi @darkhan-s @sisrfeng soft teacher is also a great job, you can refer to https://github.com/microsoft/SoftTeacher. It is also implemented based on mm, and you can build your own network structure by replacing the two-stage detector in it with a single-stage detector.