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

RetinaNet object detection (take 2) #2784

Merged
merged 41 commits into from
Oct 13, 2020
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
50f822c
Add rough implementation of RetinaNet.
hgaiser Dec 20, 2019
022f8e1
Move AnchorGenerator to a seperate file.
May 22, 2020
8e0804d
Move box similarity to Matcher.
hgaiser Jan 24, 2020
ad53194
Expose extra blocks in FPN.
hgaiser Jan 24, 2020
2a5a5be
Expose retinanet in __init__.py.
hgaiser Jan 24, 2020
49e990c
Use P6 and P7 in FPN for retinanet.
hgaiser Jan 24, 2020
b5966eb
Use parameters from retinanet for anchor generation.
hgaiser Jan 24, 2020
aab1b28
General fixes for retinanet model.
hgaiser Jan 24, 2020
c078114
Implement loss for retinanet heads.
hgaiser Jan 31, 2020
eae4ee5
Output reshaped outputs from retinanet heads.
hgaiser Feb 2, 2020
3dac477
Add postprocessing of detections.
hgaiser Feb 7, 2020
9981a3c
Small fixes.
hgaiser Mar 20, 2020
5571dfe
Remove unused argument.
hgaiser Apr 3, 2020
fc7751b
Remove python2 invocation of super.
hgaiser Apr 4, 2020
b942648
Add postprocessing for additional outputs.
hgaiser Apr 4, 2020
b619936
Add missing import of ImageList.
hgaiser Apr 17, 2020
8c86588
Remove redundant import.
hgaiser Apr 17, 2020
2934f0d
Simplify class correction.
hgaiser Apr 17, 2020
32b8e77
Fix pylint warnings.
hgaiser Apr 17, 2020
437bfe9
Remove the label adjustment for background class.
Apr 17, 2020
9e810d6
Set default score threshold to 0.05.
Apr 17, 2020
f7d8c2e
Add weight initialization for regression layer.
Apr 24, 2020
d86c437
Allow training on images with no annotations.
Apr 27, 2020
72e46f2
Use smooth_l1_loss with beta value.
Apr 27, 2020
41c90fa
Add more typehints for TorchScript conversions.
hgaiser May 15, 2020
b9daa86
Fix linting issues.
hgaiser May 15, 2020
97d63b6
Fix type hints in postprocess_detections.
hgaiser May 15, 2020
eba7e16
Fix type annotations for TorchScript.
May 18, 2020
9545059
Fix inconsistency with matched_idxs.
May 22, 2020
4865952
Add retinanet model test.
May 26, 2020
6e065be
Add missing JIT annotations.
Sep 25, 2020
7dc4c6b
Remove redundant model construction
fmassa Oct 10, 2020
640e59b
Fix bugs during training on newer PyTorch and unused params in DDP
fmassa Oct 11, 2020
23cabe3
Cleanup resnet_fpn_backbone
fmassa Oct 11, 2020
214ead7
Use L1 loss for regression
fmassa Oct 13, 2020
44a1333
Disable support for images with no annotations
fmassa Oct 13, 2020
c2f6334
Merge branch 'master' of github.com:pytorch/vision into retinanet
fmassa Oct 13, 2020
e560039
Fix retinanet tests
fmassa Oct 13, 2020
0647732
Fix Lint
fmassa Oct 13, 2020
aa6364f
Add pretrained model
fmassa Oct 13, 2020
9b62169
Add training info for retinanet
fmassa Oct 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion torchvision/models/detection/retinanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def compute_loss(self, targets, head_outputs, anchors, matched_idxs):
target_regression = self.box_coder.encode_single(matched_gt_boxes_per_image, anchors_per_image)

# compute the loss
losses.append(det_utils.smooth_l1_loss(
losses.append(torch.nn.functional.l1_loss(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why switch it to regular l1 loss?

Copy link
Member Author

Choose a reason for hiding this comment

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

This gives a 1 mAP improvement on the models, and we were still lagging a bit behind on the mAP compared to detectron2 (which has now adopted the L1 loss by default as well, see facebookresearch/detectron2@b0e2687)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah nice, wasn't expecting such a difference. What is the mAP that you are getting now? Also, wow, 37.4 mAP. That's impressive.

Copy link
Member Author

@fmassa fmassa Oct 13, 2020

Choose a reason for hiding this comment

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

Here is the mAP scores for the model I'll be uploading, with L1 loss:

IoU metric: bbox
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.364
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.558
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.383
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.193
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.400
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.490
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.315
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.506
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.558
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.386
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.595
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.699

It is still lagging behind compared to D2, but it's a bit closer. We might revisit the models in torchvision in the near future to improve mAP with latest training tricks.

bbox_regression_per_image,
target_regression,
size_average=False
Expand Down