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

Support for image with no annotations in RetinaNet #3032

Merged
merged 8 commits into from
Nov 27, 2020

Conversation

datumbox
Copy link
Contributor

@datumbox datumbox commented Nov 19, 2020

Fixes #2800

Merge after #3031, coauthored with @fmassa.

To ensure that the patch in this branch does not affect the performance of the model I retrained it and compared it with master.

Branch

retinanet_resnet50_fpn + no annotations support: boxAP=36.4
0: IoU metric: bbox
0:  Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.364
0:  Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.558
0:  Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.384
0:  Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.190
0:  Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.401
0:  Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.492
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.314
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.503
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.542
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.342
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.584
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.690

Master

retinanet_resnet50_fpn: boxAP=36.4
0: IoU metric: bbox
0:  Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.364
0:  Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.558
0:  Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.381
0:  Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.193
0:  Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.400
0:  Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.489
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.314
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.502
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.541
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.334
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.584
0:  Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.692

The above master metrics were taken from the recently merged PR on #2954.

@datumbox datumbox requested a review from fmassa November 19, 2020 16:37
@datumbox datumbox force-pushed the feature/retina_emptyannotation branch from 56f791e to c5d2868 Compare November 20, 2020 09:35
@datumbox datumbox changed the title [WIP] Support for image with no annotations in RetinaNet Support for image with no annotations in RetinaNet Nov 21, 2020
@datumbox datumbox force-pushed the feature/retina_emptyannotation branch from d6e2371 to c5d2868 Compare November 24, 2020 18:08
@datumbox
Copy link
Contributor Author

datumbox commented Nov 26, 2020

Rebasing this on the latest master fails an unrelated CI test:

Let's try rebasing later to see if this was the result of a bug on nightly upstream.

@datumbox datumbox force-pushed the feature/retina_emptyannotation branch from 860669e to c5d2868 Compare November 27, 2020 12:46
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome, much simpler and more consistent, thanks a lot Vasilis!

@datumbox
Copy link
Contributor Author

datumbox commented Nov 27, 2020

There seems to be something fishy with the failures on this PR. First of all the PR does not make any changes on the DeformConv2d operator which gets CI failures. Details:

  • The commit c5d2868, passed all CI test on 20th of November (CI logs)
  • Rebasing on latest master with commit 860669e, failed CI tests on 27th of November (CI logs)
  • Undoing the rebase and force pushing the commit c5d2868, passes all the CI test on 27th of November (CI logs)

I tried rebasing multiple times and every time I push the change it fails. Every time I undo the the rebase it succeeds.

@datumbox
Copy link
Contributor Author

I did a dummy PR #3054 to remove the test introduced and rebase and it works. It seems that the DeformConv2d test for autocast is flaky and we hit a bad seed. I'm going to try to fix this here by setting the seed to a different value.

Copy link
Contributor Author

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple of comments to explain the flakiness we observed for future reference.

@@ -128,6 +128,15 @@ def test_forward_negative_sample_krcnn(self):
self.assertEqual(loss_dict["loss_rpn_box_reg"], torch.tensor(0.))
self.assertEqual(loss_dict["loss_keypoint"], torch.tensor(0.))

def test_forward_negative_sample_retinanet(self):
model = torchvision.models.detection.retinanet_resnet50_fpn(
num_classes=2, min_size=100, max_size=100)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of this model initialisation leads to the use of a different random seed on a separate test. See below.

test/test_ops.py Show resolved Hide resolved
@datumbox datumbox merged commit 4ab46e5 into pytorch:master Nov 27, 2020
@datumbox datumbox deleted the feature/retina_emptyannotation branch November 27, 2020 18:14
zhiqwang added a commit to zhiqwang/yolort that referenced this pull request Nov 27, 2020
torchscript support `torch.dtype` now, refer to pytorch/vision#3032
vfdev-5 pushed a commit to Quansight/vision that referenced this pull request Dec 4, 2020
* Enable support for images without annotations

* Ensuring gradient propagates to RegressionHead.

* Rewriting losses to remove branching.

* Fix the seed on DeformConv autocast test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for image with no annotations in RetinaNet
3 participants