-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
add SQR for Deformable DETR #8579
Changes from 5 commits
d57e190
87419f9
06660a5
3ee85c5
7f125c8
9fd4d7e
9697fd6
53f5f69
8669316
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
architecture: DETR | ||
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_vb_normal_pretrained.pdparams | ||
hidden_dim: 256 | ||
use_focal_loss: True | ||
|
||
|
||
DETR: | ||
backbone: ResNet | ||
transformer: QRDeformableTransformer | ||
detr_head: DeformableDETRHead | ||
post_process: DETRPostProcess | ||
|
||
|
||
ResNet: | ||
# index 0 stands for res2 | ||
depth: 50 | ||
norm_type: bn | ||
freeze_at: 0 | ||
return_idx: [1, 2, 3] | ||
lr_mult_list: [0.0, 0.1, 0.1, 0.1] | ||
num_stages: 4 | ||
|
||
|
||
QRDeformableTransformer: | ||
num_queries: 300 | ||
position_embed_type: sine | ||
nhead: 8 | ||
num_encoder_layers: 6 | ||
num_decoder_layers: 6 | ||
dim_feedforward: 1024 | ||
dropout: 0.1 | ||
activation: relu | ||
num_feature_levels: 4 | ||
num_encoder_points: 4 | ||
num_decoder_points: 4 | ||
start_q: [0, 0, 1, 2, 4, 7, 12] | ||
end_q: [1, 2, 4, 7, 12, 20, 33] | ||
|
||
|
||
DeformableDETRHead: | ||
num_mlp_layers: 3 | ||
|
||
|
||
DETRLoss: | ||
loss_coeff: {class: 2, bbox: 5, giou: 2} | ||
aux_loss: True | ||
|
||
|
||
HungarianMatcher: | ||
matcher_coeff: {class: 2, bbox: 5, giou: 2} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
worker_num: 4 | ||
TrainReader: | ||
sample_transforms: | ||
- Decode: {} | ||
- RandomFlip: {prob: 0.5} | ||
- RandomSelect: { transforms1: [ RandomShortSideResize: { short_side_sizes: [ 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800 ], max_size: 1333 } ], | ||
transforms2: [ | ||
RandomShortSideResize: { short_side_sizes: [ 400, 500, 600 ] }, | ||
RandomSizeCrop: { min_size: 384, max_size: 600 }, | ||
RandomShortSideResize: { short_side_sizes: [ 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800 ], max_size: 1333 } ] | ||
} | ||
- NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]} | ||
- NormalizeBox: {} | ||
- BboxXYXY2XYWH: {} | ||
- Permute: {} | ||
batch_transforms: | ||
- PadMaskBatch: {pad_to_stride: -1, return_pad_mask: true} | ||
batch_size: 4 | ||
shuffle: true | ||
drop_last: true | ||
collate_batch: false | ||
use_shared_memory: false | ||
|
||
|
||
EvalReader: | ||
sample_transforms: | ||
- Decode: {} | ||
- Resize: {target_size: [800, 1333], keep_ratio: True} | ||
- NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]} | ||
- Permute: {} | ||
batch_size: 1 | ||
shuffle: false | ||
drop_last: false | ||
|
||
|
||
TestReader: | ||
sample_transforms: | ||
- Decode: {} | ||
- Resize: {target_size: [800, 1333], keep_ratio: True} | ||
- NormalizeImage: {is_scale: true, mean: [0.485,0.456,0.406], std: [0.229, 0.224,0.225]} | ||
- Permute: {} | ||
batch_size: 1 | ||
shuffle: false | ||
drop_last: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
epoch: 50 | ||
|
||
LearningRate: | ||
base_lr: 0.0002 | ||
schedulers: | ||
- !PiecewiseDecay | ||
gamma: 0.1 | ||
milestones: [40] | ||
use_warmup: false | ||
|
||
OptimizerBuilder: | ||
clip_grad_by_norm: 0.1 | ||
regularizer: false | ||
optimizer: | ||
type: AdamW | ||
weight_decay: 0.0001 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
_BASE_: [ | ||
'../datasets/coco_detection.yml', | ||
'../runtime.yml', | ||
'_base_/deformable_detr_sqr_r50.yml', | ||
'_base_/deformable_detr_sqr_reader.yml', | ||
] | ||
weights: output/deformable_detr_sqr_r50_12e_coco/model_final | ||
find_unused_parameters: True | ||
|
||
|
||
# a standard 1x schedule | ||
epoch: 12 | ||
|
||
LearningRate: | ||
base_lr: 0.0002 | ||
schedulers: | ||
- !PiecewiseDecay | ||
gamma: 0.1 | ||
milestones: [8, 11] | ||
use_warmup: false | ||
|
||
OptimizerBuilder: | ||
clip_grad_by_norm: 0.1 | ||
regularizer: false | ||
optimizer: | ||
type: AdamW | ||
weight_decay: 0.0001 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_BASE_: [ | ||
'../datasets/coco_detection.yml', | ||
'../runtime.yml', | ||
'_base_/deformable_sqr_optimizer_1x.yml', | ||
'_base_/deformable_detr_sqr_r50.yml', | ||
'_base_/deformable_detr_sqr_reader.yml', | ||
] | ||
weights: output/deformable_detr_sqr_r50_1x_coco/model_final | ||
find_unused_parameters: True |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,9 +122,10 @@ def forward(self, | |
out_bbox.unsqueeze(1) - tgt_bbox.unsqueeze(0)).abs().sum(-1) | ||
|
||
# Compute the giou cost betwen boxes | ||
cost_giou = self.giou_loss( | ||
giou_loss = self.giou_loss( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这块改的原因是什么 对其他模型通用嘛 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这块原本的cost_giou是算错的,不过对后面计算linear_sum_assignment没有影响,所以其他模型也没有影响 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议你新增一个flag 其他的模型就不需要重新验证了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
我觉得不需要,cost_giou只被用在计算C,C只被用在计算linear_sum_assignment,而cost_giou整体增大一个常数对linear_sum_assignment是没有影响的 |
||
bbox_cxcywh_to_xyxy(out_bbox.unsqueeze(1)), | ||
bbox_cxcywh_to_xyxy(tgt_bbox.unsqueeze(0))).squeeze(-1) | ||
cost_giou = giou_loss - 1 | ||
|
||
# Final cost matrix | ||
C = self.matcher_coeff['class'] * cost_class + \ | ||
|
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.
这块改的原因是什么
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.
为了避免多卡eval时,重复写入造成文件损坏。
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.
现在的ppdet多卡eval逻辑是不对的 没有mege最终的结果的逻辑 这块还保持原来的逻辑吧