httle / ARS-DETR

Apache License 2.0
42 stars 7 forks source link

What's the meaning of the `self.rotate_deform_attn`? #16

Open kouyuanbo opened 3 months ago

kouyuanbo commented 3 months ago

Here is some code in the file dn_ars_rotated_transformer.py.It ensures the reference_angle_input in [-pi/4,pi/4],is it necessary? Abd why should do this?

if self.rotate_deform_attn:
    index = (reference_angle_input > math.pi / 4).view(-1) | \
            (reference_angle_input < -math.pi / 4).view(-1)
    bs, q_num, layer_num, points_num = reference_points_input.shape
    reference_points_input = reference_points_input.view(bs * q_num, layer_num, points_num).contiguous()
    reference_points_input[index, :, 2], reference_points_input[index, :, 3] = \
        reference_points_input[index, :, 3], reference_points_input[index, :, 2]
    reference_points_input = reference_points_input.view(bs, q_num, layer_num, points_num).contiguous()
    reference_angle_input = (reference_angle_input + math.pi / 4 - reference_angle_input * 1e-10) % \
                            (math.pi / 2) - math.pi / 4 + reference_angle_input * 1e-10
httle commented 3 months ago

The initial bias of sampling offsets are located in eight directions of the square, so the suitable range would be [-pi/4, pi/4]. We have also tested that adding this constraint results in better effects.