Skip to content

Commit

Permalink
pick 9164 (#9231)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangna11BD authored Dec 6, 2024
1 parent aba23bb commit b972633
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion ppdet/modeling/heads/roi_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def __init__(self,
self.canonical_size = canonical_size
self.start_level = start_level
self.end_level = end_level
self.aligned = False # TODO: npu kernel do not support aligned=True
if 'npu' in paddle.device.get_device():
self.aligned = False
else:
self.aligned = aligned

@classmethod
def from_config(cls, cfg, input_shape):
Expand Down
8 changes: 5 additions & 3 deletions ppdet/modeling/proposal_generator/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ def rpn_anchor_target(anchors,
fg_inds, bg_inds = subsample_labels(match_labels, rpn_batch_size_per_im,
rpn_fg_fraction, 0, use_random)
# Fill with the ignore label (-1), then set positive and negative labels
labels = paddle.full(match_labels.shape, -1, dtype='int32')
labels = paddle.full(match_labels.shape, -1, dtype='float32')
if bg_inds.shape[0] > 0:
labels = paddle.scatter(labels, bg_inds, paddle.zeros_like(bg_inds))
bg_inds = bg_inds % labels.shape[0]
labels = paddle.scatter(labels, bg_inds, paddle.zeros_like(bg_inds, dtype=labels.dtype))
if fg_inds.shape[0] > 0:
labels = paddle.scatter(labels, fg_inds, paddle.ones_like(fg_inds))
fg_inds = fg_inds % labels.shape[0]
labels = paddle.scatter(labels, fg_inds, paddle.ones_like(fg_inds, dtype=labels.dtype))
# Step3: make output
if gt_bbox.shape[0] == 0:
matched_gt_boxes = paddle.zeros([matches.shape[0], 4])
Expand Down

0 comments on commit b972633

Please sign in to comment.