IDEA-Research / DAB-DETR

[ICLR 2022] Official implementation of the paper "DAB-DETR: Dynamic Anchor Boxes are Better Queries for DETR"
Apache License 2.0
498 stars 86 forks source link

The meaning of num_feature_levels. #20

Open TsingWei opened 2 years ago

TsingWei commented 2 years ago

Thanks for your great and detailed code!

In dab_deformable_detr.py, is this part about dealing with the insufficient channel of features (for Deformable DETR)?

https://github.com/IDEA-opensource/DAB-DETR/blob/309f6ad92af7a62d7732c1bdf1e0c7a69a7bdaef/models/dab_deformable_detr/dab_deformable_detr.py#L169-L181

It seems that the last channel of features is put to backbone[1] repeatedly. (channel? or something else?) Could you please help me understand that?

SlongLiu commented 2 years ago

Yes, it is. By default, num_feature_levels=4 but 3 different scales are extracted from the backbone. Hence it will 2x upsample the highest feature map(C4) as the 4th feature level.

TsingWei commented 2 years ago

Thanks! Here come another confusing lines, especially Line#392: https://github.com/IDEA-opensource/DAB-DETR/blob/309f6ad92af7a62d7732c1bdf1e0c7a69a7bdaef/models/dab_deformable_detr/deformable_transformer.py#L390-L392 Why concat src_valid_ratios with itself, and then multiplied to reference_points?

When I alter the param num_feature_levels to another one, like 3, the Exceptions of mismatched dim for matrix mul(or ele-wise mul) happens.

By default, num_feature_levels is 4, so the mul operation is performed "well". Is it a bug?

Besides, I noticed that there is no batch_size dimension in reference_points. Does that mean various batches share the same reference_points?