Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[solution of errors]'the dim of decoded rois' and'illegal memory acecess' #49

Open
Jacky-gsq opened this issue Jul 29, 2020 · 0 comments

Comments

@Jacky-gsq
Copy link

It cost me two days to solve the error and i almost try every solutions on the network. Luckily, it work.

Change the code of bbox_decode() function in bbox_transform.py as follows:

`def bbox_decode(rois, bbox_pred, batch_size, classes, im_info, training):
rois_ = rois.detach()
boxes = rois_[:, :, 1:5]

if cfg.TEST.BBOX_REG:
    # Apply bounding-box regression deltas
    box_deltas = bbox_pred.data
    if cfg.TRAIN.BBOX_NORMALIZE_TARGETS_PRECOMPUTED:
        # Optionally normalize targets by a precomputed mean and stdev
        if training:
            box_deltas = box_deltas.view(-1, 4) * torch.FloatTensor(cfg.TRAIN.BBOX_NORMALIZE_STDS).cuda() \
                         + torch.FloatTensor(cfg.TRAIN.BBOX_NORMALIZE_MEANS).cuda()
            box_deltas = box_deltas.view(batch_size, -1, 4)
        else:
            box_deltas = box_deltas.view(-1, 4) * torch.FloatTensor(cfg.TRAIN.BBOX_NORMALIZE_STDS).cuda() \
                         + torch.FloatTensor(cfg.TRAIN.BBOX_NORMALIZE_MEANS).cuda()
            box_deltas = box_deltas.view(batch_size, -1, 4 * classes)

    pred_boxes = bbox_transform_inv(boxes, box_deltas, batch_size)
    pred_boxes = clip_boxes(pred_boxes, im_info, batch_size)
else:
    # Simply repeat the boxes, once for each class
    pred_boxes = boxes
pred_boxes = pred_boxes.view(batch_size, -1, 4)
ret_boxes = pred_boxes.new(pred_boxes.size(0), pred_boxes.size(1), pred_boxes.size(2)+1)
ret_boxes[:, :, 1:pred_boxes.size(2) + 1] = pred_boxes
for b in range(batch_size):
    ret_boxes[b, :, 0] = b
# if not training:
#    pred_boxes.view(batch_size, -1, 4 * classes)
return ret_boxes`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant