Faster-rcnn.pytorch: TypeError: index(): argument 'indices' (position 1) must be tuple of Tensors, not Tensor in proposal_target_layer_cascade.py

Created on 14 Jul 2018  路  2Comments  路  Source: jwyang/faster-rcnn.pytorch

My environment is cuda9.0, python3.6, pytorch0.4. I use pascal_voc dataset.
When I run trainval_net.py, I got this error. How to solve this?
labels = gt_boxes[:, :, 4].contiguous().view(-1).index(offset.view(-1)).view(batch_size, -1) TypeError: index(): argument 'indices' (position 1) must be tuple of Tensors, not Tensor
The error line is in class _ProposalTargetLayer(nn.Module),
def _sample_rois_pytorch(self, all_rois, gt_boxes, fg_rois_per_image, rois_per_image, num_classes):
` def _sample_rois_pytorch(self, all_rois, gt_boxes, fg_rois_per_image, rois_per_image, num_classes):
"""Generate a random sample of RoIs comprising foreground and background
examples.
"""
# overlaps: (rois x gt_boxes)

    overlaps = bbox_overlaps_batch(all_rois, gt_boxes)

    max_overlaps, gt_assignment = torch.max(overlaps, 2)

    batch_size = overlaps.size(0)
    num_proposal = overlaps.size(1)
    num_boxes_per_img = overlaps.size(2)

    offset = torch.arange(0, batch_size)*gt_boxes.size(1)
    offset = offset.view(-1, 1).type_as(gt_assignment) + gt_assignment

    labels = gt_boxes[:, :, 4].contiguous().view(-1).index(offset.view(-1)).view(batch_size, -1)`

Most helpful comment

Use index() like this: index((offset.view(-1),))

All 2 comments

Use index() like this: index((offset.view(-1),))

@gullalc Thanks a lot. I used [] replace index(), it also works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Feiyu-Zhang picture Feiyu-Zhang  路  5Comments

herrickli picture herrickli  路  3Comments

GPaolo picture GPaolo  路  5Comments

EmmaSRH picture EmmaSRH  路  4Comments

HaiminZhang picture HaiminZhang  路  3Comments