Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: Alpha of ciou loss should not have gradient. #5835

Merged
merged 4 commits into from
Aug 25, 2021

Conversation

RangiLyu
Copy link
Member

@RangiLyu RangiLyu commented Aug 9, 2021

In the official implementation of CIOU loss, the alpha does not have gradient. And when iou<=0.5, alpha=0. Refer to:

https://github.com/Zzh-tju/CIoU/blob/d8573fc9ef221e89fd0dfeef42027acd764c49ff/layers/modules/multibox_loss.py#L53

@RangiLyu RangiLyu linked an issue Aug 9, 2021 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Aug 9, 2021

Codecov Report

Merging #5835 (b1c65cc) into master (bcd3b50) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head b1c65cc differs from pull request most recent head 1ffc669. Consider uploading reports for the commit 1ffc669 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5835      +/-   ##
==========================================
- Coverage   67.09%   67.06%   -0.03%     
==========================================
  Files         301      301              
  Lines       23335    23334       -1     
  Branches     3841     3841              
==========================================
- Hits        15657    15650       -7     
  Misses       6884     6884              
- Partials      794      800       +6     
Flag Coverage Δ
unittests 67.06% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmdet/datasets/pipelines/formating.py 66.37% <100.00%> (ø)
mmdet/models/losses/iou_loss.py 94.76% <100.00%> (+0.05%) ⬆️
mmdet/models/dense_heads/dense_test_mixins.py 41.02% <0.00%> (-2.57%) ⬇️
mmdet/models/roi_heads/test_mixins.py 72.34% <0.00%> (-2.13%) ⬇️
mmdet/datasets/custom.py 63.37% <0.00%> (-0.22%) ⬇️
mmdet/datasets/pipelines/transforms.py 76.47% <0.00%> (-0.14%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 682f03d...1ffc669. Read the comment docs.

@ZwwWayne
Copy link
Collaborator

ZwwWayne commented Aug 9, 2021

Suggest updating unit test

@ZwwWayne ZwwWayne requested a review from AronLin August 10, 2021 07:03
@ZwwWayne
Copy link
Collaborator

Add a faster rcnn model with CIoULoss

@RangiLyu
Copy link
Member Author

Training results of CIOU Faster R-CNN

Before:

Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.378
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=1000 ] = 0.583
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=1000 ] = 0.408
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.216
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.412
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.490
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.523
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=300 ] = 0.523
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=1000 ] = 0.523
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.324
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.559
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.661 

After:

Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.378
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=1000 ] = 0.583
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=1000 ] = 0.408
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.216
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.413
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.492
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.521
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=300 ] = 0.521
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=1000 ] = 0.521
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.323
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.561
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.665

Almost the same.

@RangiLyu
Copy link
Member Author

CIOU with weight=12 refering from the paper

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.380
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=1000 ] = 0.583
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=1000 ] = 0.412
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.218
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.418
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.495
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.527
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=300 ] = 0.527
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=1000 ] = 0.527
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1000 ] = 0.328
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1000 ] = 0.566
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=1000 ] = 0.670

@ZwwWayne
Copy link
Collaborator

can be merged after update config and model link

@RangiLyu RangiLyu changed the title [Fix]: Alpha of ciou loss does not have gradient. [Fix]: Alpha of ciou loss should not have gradient. Aug 25, 2021
@ZwwWayne ZwwWayne merged commit 6aff661 into open-mmlab:master Aug 25, 2021
guigarfr pushed a commit to guigarfr/mmdetection that referenced this pull request Sep 6, 2021
* [Fix]: Alpha of ciou loss does not have gradient.

* add ciou faster rcnn

* update loss weight
@RangiLyu RangiLyu deleted the fix/ciou branch January 13, 2022 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

alpha of CIoU loss
3 participants