From f42868091282171c3f2e438a61be9cfc36d9e631 Mon Sep 17 00:00:00 2001 From: Ren Tianhe <48727989+rentainhe@users.noreply.github.com> Date: Tue, 18 Oct 2022 12:59:27 +0800 Subject: [PATCH] [Enhance] Update deformable-detr-two-stage training results (#103) * refine README * set cost class=1 * fix typos * update table * update download links * refine readme and docs Co-authored-by: ntianhe ren --- README.md | 2 +- docs/source/tutorials/Model_Zoo.md | 16 ++++++++-------- .../modeling/dab_deformable_transformer.py | 4 ++-- projects/deformable_detr/README.md | 4 ++-- ...formable_detr_r50_with_box_refinement_50ep.py | 13 ------------- .../configs/models/deformable_detr_r50.py | 2 +- .../modeling/deformable_transformer.py | 4 ++-- projects/dino/modeling/dino_transformer.py | 4 ++-- .../modeling/dn_deformable_transformer.py | 4 ++-- 9 files changed, 20 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 77dc4788..9f5fc3da 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Results and models are available in [model zoo](https://detrex.readthedocs.io/en Supported methods - [x] [DETR (ECCV'2020)](./projects/detr/) -- [x] [Deformable-DETR (ICLR'2021 Oral)](./projects/dab_deformable_detr/) +- [x] [Deformable-DETR (ICLR'2021 Oral)](./projects/deformable_detr/) - [x] [Conditional-DETR (ICCV'2021)](./projects/conditional_detr/) - [x] [DAB-DETR (ICLR'2022)](./projects/dab_detr/) - [x] [DAB-Deformable-DETR (ICLR'2022)](./projects/dab_deformable_detr/) diff --git a/docs/source/tutorials/Model_Zoo.md b/docs/source/tutorials/Model_Zoo.md index b1f5b50a..0d8f14cd 100644 --- a/docs/source/tutorials/Model_Zoo.md +++ b/docs/source/tutorials/Model_Zoo.md @@ -31,8 +31,8 @@ Here we provides our pretrained baselines in `detrex beta v0.1.0`. And more pret R50 IN1k 50 -47.28 - model +48.19 + model @@ -158,42 +158,42 @@ Here we provides our pretrained baselines in `detrex beta v0.1.0`. And more pret 49.95 model - DINO-Swin-T-224-4scale + DINO-Swin-T-224-4Scale Swin-Tiny-224 IN1k 12 51.30 model - DINO-Swin-T-224-4scale + DINO-Swin-T-224-4Scale Swin-Tiny-224 IN22k to IN1k 12 52.50 model - DINO-Swin-S-224-4scale + DINO-Swin-S-224-4Scale Swin-Small-224 IN1k 12 52.96 model - DINO-Swin-B-384-4scale + DINO-Swin-B-384-4Scale Swin-Base-384 IN22k to IN1k 12 55.83 model - DINO-Swin-L-224-4scale + DINO-Swin-L-224-4Scale Swin-Large-224 IN22k to IN1k 12 56.92 model - DINO-Swin-L-384-4scale + DINO-Swin-L-384-4Scale Swin-Large-384 IN22k to IN1k 12 diff --git a/projects/dab_deformable_detr/modeling/dab_deformable_transformer.py b/projects/dab_deformable_detr/modeling/dab_deformable_transformer.py index 056c08db..30b7aa40 100644 --- a/projects/dab_deformable_detr/modeling/dab_deformable_transformer.py +++ b/projects/dab_deformable_detr/modeling/dab_deformable_transformer.py @@ -311,7 +311,7 @@ def get_reference_points(spatial_shapes, valid_ratios, device): Args: spatial_shapes (Tensor): The shape of all feature maps, has shape (num_level, 2). - valid_ratios (Tensor): The radios of valid + valid_ratios (Tensor): The ratios of valid points on the feature map, has shape (bs, num_levels, 2) device (obj:`device`): The device where @@ -337,7 +337,7 @@ def get_reference_points(spatial_shapes, valid_ratios, device): return reference_points def get_valid_ratio(self, mask): - """Get the valid radios of feature maps of all level.""" + """Get the valid ratios of feature maps of all levels.""" _, H, W = mask.shape valid_H = torch.sum(~mask[:, :, 0], 1) valid_W = torch.sum(~mask[:, 0, :], 1) diff --git a/projects/deformable_detr/README.md b/projects/deformable_detr/README.md index 5a1fcc1e..e9cc22fe 100644 --- a/projects/deformable_detr/README.md +++ b/projects/deformable_detr/README.md @@ -34,8 +34,8 @@ Here we provide the pretrained `Deformable-DETR` weights based on detrex. R-50 IN1k 50 -47.28 - model +48.19 + model diff --git a/projects/deformable_detr/configs/deformable_detr_r50_with_box_refinement_50ep.py b/projects/deformable_detr/configs/deformable_detr_r50_with_box_refinement_50ep.py index 7287d710..ab2c2cc5 100644 --- a/projects/deformable_detr/configs/deformable_detr_r50_with_box_refinement_50ep.py +++ b/projects/deformable_detr/configs/deformable_detr_r50_with_box_refinement_50ep.py @@ -3,19 +3,6 @@ # modify model config # set loss_class to 1.0 brings better results for deformable-detr-box-refinement under lr=1e-4 model.with_box_refine = True -model.criterion.weight_dict = { - "loss_class": 1.0, - "loss_bbox": 5.0, - "loss_giou": 2.0, -} -if model.aux_loss: - weight_dict = model.criterion.weight_dict - aux_weight_dict = {} - for i in range(model.transformer.decoder.num_layers - 1): - aux_weight_dict.update({k + f"_{i}": v for k, v in weight_dict.items()}) - aux_weight_dict.update({k + "_enc": v for k, v in weight_dict.items()}) - weight_dict.update(aux_weight_dict) - model.criterion.weight_dict = weight_dict # modify training config train.init_checkpoint = "detectron2://ImageNetPretrained/torchvision/R-50.pkl" diff --git a/projects/deformable_detr/configs/models/deformable_detr_r50.py b/projects/deformable_detr/configs/models/deformable_detr_r50.py index b4eef2fe..2936ed44 100644 --- a/projects/deformable_detr/configs/models/deformable_detr_r50.py +++ b/projects/deformable_detr/configs/models/deformable_detr_r50.py @@ -87,7 +87,7 @@ gamma=2.0, ), weight_dict={ - "loss_class": 2.0, + "loss_class": 1.0, "loss_bbox": 5.0, "loss_giou": 2.0, }, diff --git a/projects/deformable_detr/modeling/deformable_transformer.py b/projects/deformable_detr/modeling/deformable_transformer.py index 06456f2b..fc462ef3 100644 --- a/projects/deformable_detr/modeling/deformable_transformer.py +++ b/projects/deformable_detr/modeling/deformable_transformer.py @@ -304,7 +304,7 @@ def get_reference_points(spatial_shapes, valid_ratios, device): Args: spatial_shapes (Tensor): The shape of all feature maps, has shape (num_level, 2). - valid_ratios (Tensor): The radios of valid + valid_ratios (Tensor): The ratios of valid points on the feature map, has shape (bs, num_levels, 2) device (obj:`device`): The device where @@ -330,7 +330,7 @@ def get_reference_points(spatial_shapes, valid_ratios, device): return reference_points def get_valid_ratio(self, mask): - """Get the valid radios of feature maps of all level.""" + """Get the valid ratios of feature maps of all levels.""" _, H, W = mask.shape valid_H = torch.sum(~mask[:, :, 0], 1) valid_W = torch.sum(~mask[:, 0, :], 1) diff --git a/projects/dino/modeling/dino_transformer.py b/projects/dino/modeling/dino_transformer.py index 52ed53f1..5abd2510 100644 --- a/projects/dino/modeling/dino_transformer.py +++ b/projects/dino/modeling/dino_transformer.py @@ -312,7 +312,7 @@ def get_reference_points(spatial_shapes, valid_ratios, device): Args: spatial_shapes (Tensor): The shape of all feature maps, has shape (num_level, 2). - valid_ratios (Tensor): The radios of valid + valid_ratios (Tensor): The ratios of valid points on the feature map, has shape (bs, num_levels, 2) device (obj:`device`): The device where @@ -338,7 +338,7 @@ def get_reference_points(spatial_shapes, valid_ratios, device): return reference_points def get_valid_ratio(self, mask): - """Get the valid radios of feature maps of all level.""" + """Get the valid ratios of feature maps of all levels.""" _, H, W = mask.shape valid_H = torch.sum(~mask[:, :, 0], 1) valid_W = torch.sum(~mask[:, 0, :], 1) diff --git a/projects/dn_deformable_detr/modeling/dn_deformable_transformer.py b/projects/dn_deformable_detr/modeling/dn_deformable_transformer.py index f7f883a2..73584ca8 100644 --- a/projects/dn_deformable_detr/modeling/dn_deformable_transformer.py +++ b/projects/dn_deformable_detr/modeling/dn_deformable_transformer.py @@ -301,7 +301,7 @@ def get_reference_points(spatial_shapes, valid_ratios, device): Args: spatial_shapes (Tensor): The shape of all feature maps, has shape (num_level, 2). - valid_ratios (Tensor): The radios of valid + valid_ratios (Tensor): The ratios of valid points on the feature map, has shape (bs, num_levels, 2) device (obj:`device`): The device where @@ -326,7 +326,7 @@ def get_reference_points(spatial_shapes, valid_ratios, device): return reference_points def get_valid_ratio(self, mask): - """Get the valid radios of feature maps of all level.""" + """Get the valid ratios of feature maps of all levels.""" _, H, W = mask.shape valid_H = torch.sum(~mask[:, :, 0], 1) valid_W = torch.sum(~mask[:, 0, :], 1)