-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Improve speed/accuracy of *RCNN models by introducing a score threshold on RPN #3205
Conversation
33cd476
to
ae8b92e
Compare
6585030
to
8c38842
Compare
6606123
to
264d4d7
Compare
264d4d7
to
c42e309
Compare
I think @masahi had opinions on it, I didn't really look at it in detail. |
well not really an opinion, but nothing changes by default and the only extra costs are one additional parameter (of which there are already many) and one call to sigmoid and where, both negligible. So I'd say why not. |
Codecov Report
@@ Coverage Diff @@
## master #3205 +/- ##
==========================================
+ Coverage 73.45% 73.49% +0.03%
==========================================
Files 102 101 -1
Lines 9329 9241 -88
Branches 1494 1480 -14
==========================================
- Hits 6853 6792 -61
+ Misses 2012 1989 -23
+ Partials 464 460 -4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
The failing tests on ONNX are not related to this PR. The master is broken (see #3251). |
… on RPN (#3205) Summary: * Introduce small score threshold on rpn * Adding docs and fixing keypoint and mask. * Making value 0.0 by default for BC. * Fixing for onnx. * Update threshold. * Removing non-default threshold from reference scripts. Reviewed By: datumbox Differential Revision: D25954569 fbshipit-source-id: a429a13c7153f0b87c377464d3d062aa28370002 Co-authored-by: Francisco Massa <fvsmassa@gmail.com>
Related to #3198
This PR investigates whether there is any benefit in adding a score threshold for RegionProposalNetwork similar to what we do for RoIHeads. The idea is to reduce the number of candidates before we do the expensive NMS step and we assess the speed and the accuracy changes from the change.
Effects of Threshold on Inference (pre-trained models)
First of all let's check the effect of various threshold values on inference in the pre-trained models. This will give us an idea on how sensitive the accuracy is to different values (this will be used later once we train the models from scratch):
Before every experiment we adapt manually the threshold directly on the source code. Here are the results for different values:
threshold=0.0
Submitted batch job 34066683threshold=0.05
Submitted batch job 34066468threshold=0.1
Submitted batch job 34067146threshold=0.5
Submitted batch job 34067396threshold=0.75
Submitted batch job 34067628threshold=0.9
Submitted batch job 34067969threshold=0.95
Submitted batch job 34068760threshold=1.0
Submitted batch job 34067918Based on the above stats we observe that:
Effects of Threshold on Training & Accuracy
Based on the above we will use a moderate threshold of 0.5 and retrain all the existing *RCNN models. All baselines are taken from the stats estimated at #2954 (the PR's branch stats are our current master).
fasterrcnn_resnet50_fpn
Branch: boxAP=38.1, trainingTime=11:31:39
Submitted batch job 34069542Master: boxAP=38.0, trainingTime=12:10:40
Submitted batch job 32444455maskrcnn_resnet50_fpn
Branch: boxAP=39.0, maskAP=35.1, trainingTime=14:14:00
Submitted batch job 34144523Master: boxAP=38.7, maskAP=34.7, trainingTime=14:43:42
Submitted batch job 32444457keypointrcnn_resnet50_fpn
Branch: boxAP=55.6, kpAP=63.9, trainingTime=13:25:04
Submitted batch job 34144524Master: boxAP=55.5, kpAP=65.1, trainingTime=14:30:21
Submitted batch job 32444458Based on the above we see that the introduction of a moderate threshold enables us to achieve a speed improvement of roughly 3.5-7.5% in training time without hurting the accuracy. Note that the above thresholds are not tuned and one could potentially achieve greater gains by using different thresholds.
Edit:
The keypointrcnn_resnet50_fpn seems to require a slightly different threshold to boost accuracy. Using a value of 0.1 yields the following results:
Branch: boxAP=56.1, kpAP=64.7, trainingTime=13:51:37
Submitted batch job 34346469The above indicates that the threshold can be beneficial both for improving the accuracy metrics and speed but some tuning might be required to achieve best results.