Skip to content

Commit

Permalink
fix type promotion (PaddlePaddle#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyuwenyu authored May 14, 2024
1 parent 9fa404a commit 2505c4a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion paddlemix/models/groundingdino/ms_deform_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def forward(
)

if reference_points.shape[-1] == 2:
offset_normalizer = value_spatial_shapes.flip([1]).reshape([1, 1, 1, self.num_levels, 1, 2])
offset_normalizer = value_spatial_shapes.flip([1]).reshape([1, 1, 1, self.num_levels, 1, 2]).astype(sampling_offsets.dtype)
sampling_locations = (
reference_points.reshape([bs, Len_q, 1, self.num_levels, 1, 2]) + sampling_offsets / offset_normalizer
)
Expand Down
3 changes: 1 addition & 2 deletions paddlemix/models/groundingdino/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ def gen_encoder_output_proposals(
grid = paddle.concat([grid_x.unsqueeze(-1), grid_y.unsqueeze(-1)], -1) # H_, W_, 2

scale = paddle.concat([valid_W.unsqueeze(-1), valid_H.unsqueeze(-1)], 1).reshape([N_, 1, 1, 2])
grid = (grid.unsqueeze(0).tile([N_, 1, 1, 1]) + 0.5) / scale
grid = (grid.unsqueeze(0).tile([N_, 1, 1, 1]) + 0.5) / scale.astype(grid.dtype)

if learnedwh is not None:
# import ipdb; ipdb.set_trace()
wh = paddle.ones_like(grid) * learnedwh.sigmoid() * (2.0**lvl)
else:
wh = paddle.ones_like(grid) * 0.05 * (2.0**lvl)
Expand Down

0 comments on commit 2505c4a

Please sign in to comment.