@@ -16,10 +16,10 @@ def forward(self, anchors, regression):
1616 Returns:
1717
1818 """
19- y_centers_a = ( anchors [..., 0 ] + anchors [..., 2 ]) / 2
20- x_centers_a = ( anchors [..., 1 ] + anchors [..., 3 ]) / 2
21- ha = anchors [..., 2 ] - anchors [..., 0 ]
22- wa = anchors [..., 3 ] - anchors [..., 1 ]
19+ x_centers_a = anchors [..., 0 ]
20+ y_centers_a = anchors [..., 1 ]
21+ wa = anchors [..., 2 ]
22+ ha = anchors [..., 3 ]
2323
2424 w = regression [..., 3 ].exp () * wa
2525 h = regression [..., 2 ].exp () * ha
@@ -130,6 +130,14 @@ def forward(self, image, dtype=torch.float32):
130130 anchor_boxes = np .vstack (boxes_all )
131131
132132 anchor_boxes = torch .from_numpy (anchor_boxes .astype (dtype )).to (image .device )
133+
134+ # transform
135+ y_centers_a = (anchor_boxes [..., 0 ] + anchor_boxes [..., 2 ]) / 2
136+ x_centers_a = (anchor_boxes [..., 1 ] + anchor_boxes [..., 3 ]) / 2
137+ ha = anchor_boxes [..., 2 ] - anchor_boxes [..., 0 ]
138+ wa = anchor_boxes [..., 3 ] - anchor_boxes [..., 1 ]
139+
140+ anchor_boxes = torch .stack ([x_centers_a , y_centers_a , wa , ha ], 1 )
133141 anchor_boxes = anchor_boxes .unsqueeze (0 )
134142
135143 # save it for later use to reduce overhead
0 commit comments