Skip to content

Commit

Permalink
Replace copy_ op in Box2BoxTransform.apply_deltas
Browse files Browse the repository at this point in the history
  • Loading branch information
apivovarov committed Mar 2, 2021
1 parent e40ddbb commit 998bc55
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions detectron2/modeling/box_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ def apply_deltas(self, deltas, boxes):
pred_w = torch.exp(dw) * widths[:, None]
pred_h = torch.exp(dh) * heights[:, None]

pred_boxes = torch.zeros_like(deltas)
pred_boxes[:, 0::4] = pred_ctr_x - 0.5 * pred_w # x1
pred_boxes[:, 1::4] = pred_ctr_y - 0.5 * pred_h # y1
pred_boxes[:, 2::4] = pred_ctr_x + 0.5 * pred_w # x2
pred_boxes[:, 3::4] = pred_ctr_y + 0.5 * pred_h # y2
return pred_boxes
x1 = pred_ctr_x - 0.5 * pred_w
y1 = pred_ctr_y - 0.5 * pred_h
x2 = pred_ctr_x + 0.5 * pred_w
y2 = pred_ctr_y + 0.5 * pred_h
pred_boxes = torch.stack((x1, y1, x2, y2), dim=-1)
return pred_boxes.reshape(deltas.shape)


@torch.jit.script
Expand Down

0 comments on commit 998bc55

Please sign in to comment.