tztztztztz / eqlv2

The official implementation of Equalization Loss v1 & v2 (CVPR 2020, 2021) based on MMDetection. https://arxiv.org/abs/2012.08548 https://arxiv.org/abs/2003.05176
Apache License 2.0
156 stars 22 forks source link

Function error #4

Closed jefferyZhan closed 3 years ago

jefferyZhan commented 3 years ago

Hi, when i used the EQL loss function, it seems there is an error in the threshold function. Take Lvis v0.5 as example: The shape of pred_class_logits is 1231, including a background class. But the shape of the return of get_image_count_frequency is 1230, excluding the background class. Then the indexerror occured. Is it because of version or exactly an error? It can be fixed by expanding the freq_info, setting the backgound frequence.

tztztztztz commented 3 years ago

Hi, the shape of pred_class_logits in EQL should be 1230 instead of 1231 since EQL uses the sigmoid loss function and does not include an objectiveness branch.

Can you give more information about the error you came across? For example, which codebase and config did you use?

jefferyZhan commented 3 years ago

I used the faster_rcnn_r50_fpn_1x_coco.py(config), LVIS v0.5 dataset, and the mmdetection. Also, I modified the rio bbox head with EQL with sigmoid function. Without modifying the freq_info, the error report is: weight[self.freqinfo < self.lambda] = 1 IndexError: The shape of the mask [1230] at index 0 does not match the shape of the indexed tensor [1231] at index 0 after modifying the freq_info, all the loss became "nan". A little bit wired.

tztztztztz commented 3 years ago

To use EQL in your own repo, please keep these in mind.

  1. change the shape of fc-cls layer to (num_classes) instead of (num_classes + 1) https://github.com/tztztztztz/eqlv2/blob/4c7ea9789446c0356f002a7bb657899961d67360/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py#L88

  2. init parameters with prior bias to avoid "nan" https://github.com/tztztztztz/eqlv2/blob/4c7ea9789446c0356f002a7bb657899961d67360/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py#L154-L156

  3. adopt your activation ways for testing https://github.com/tztztztztz/eqlv2/blob/4c7ea9789446c0356f002a7bb657899961d67360/mmdet/models/roi_heads/bbox_heads/bbox_head.py#L212-L214

However, I recommend that use this repo first and get familiar with the equalization losses

jefferyZhan commented 3 years ago

Thanks a lot~