kinredon / Harmonious-Teacher

Official implementation of the CVPR 2023 paper "Harmonious Teacher for Cross-domain Object Detection"
Apache License 2.0
26 stars 3 forks source link

The weight type of the config is different from the paper? #4

Closed zengziru closed 10 months ago

zengziru commented 10 months ago
  1. I observe that in all your configs the VFL.WEIGHT_TYPE all set to be 'iou' not the 'hm' or 'hm_rev' said in your paper. I would like to know whether the accuracy of the model can be improved if the weight_type is changed to "hm_rev". Is the best data in your paper obtained by setting weight_type to iou or hm_rev?

  2. In your paper, it seems that hm operation is only for vfloss. By observing your code, I find that hm does not seem to be used for weighting when calculating the regression loss of the boxes. Is the hm operation not used on the box regression branch? Hope to receive your reply, thank you very much!

kinredon commented 10 months ago

Hi, @zengziru:

  1. The hm is used to reweight the distillation from the teacher to the student model instead of VFL, VFL.WEIGHT_TYPE is set to iou, which is the same as Eq. (4) in the paper. You can try to use hm or hm_rev and observe whether further improve the performance or not. From my side, I do not observe obvious improvements.

  2. We use the hm to reweight the distillation for both classification and localization, you can find them in https://github.com/kinredon/Harmonious-Teacher/blob/863eda2d4fc2ced8fee228034033865e54ddc286/ht_c2f/runner.py#L409C9-L409C20, which is used to weight both classification and localization.

zengziru commented 10 months ago

Thanks a lot for your detailed reply, I will read the code again carefully.

zengziru commented 10 months ago

Hello! Based on the get_distill_loss code in the runner.py you provided, I found that: hm = (cls_prob ** self.alpha) * (iou ** self.beta) loss_uncertainty = (1 - hm) / self.cfg.TRAINER.DISTILL.UN_REGULAR_ALPHA loss_weight = torch.exp(-loss_uncertainty.detach())

But in your paper the weighting function is written like this: exp^(1-h), there seems to be a minus sign difference between the code and the formula. I wonder which version, code or paper should I refer to? Hope to get your reply, thank you very much!

kinredon commented 10 months ago

Thank you for pointing this out. You can refer to the implementation of the codebase.