cascade-rcnn_Pytorch icon indicating copy to clipboard operation
cascade-rcnn_Pytorch copied to clipboard

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

Open Jacky-gsq opened this issue 4 years ago • 0 comments

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`

Jacky-gsq avatar Jul 29 '20 16:07 Jacky-gsq