diff --git a/ppdet/modeling/heads/roi_extractor.py b/ppdet/modeling/heads/roi_extractor.py index ef0d76e300..d1e2dfd451 100644 --- a/ppdet/modeling/heads/roi_extractor.py +++ b/ppdet/modeling/heads/roi_extractor.py @@ -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): diff --git a/ppdet/modeling/proposal_generator/target.py b/ppdet/modeling/proposal_generator/target.py index 041b2c7915..e59a48005f 100644 --- a/ppdet/modeling/proposal_generator/target.py +++ b/ppdet/modeling/proposal_generator/target.py @@ -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])