Skip to content

TypeError: index(): argument 'indices' (position 1) must be tuple of Tensors, not Tensor in proposal_target_layer_cascade.py #242

Closed
@buyi1128

Description

@buyi1128

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)`

Activity

gullalc

gullalc commented on Jul 16, 2018

@gullalc

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

buyi1128

buyi1128 commented on Jul 17, 2018

@buyi1128
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gullalc@buyi1128

        Issue actions

          TypeError: index(): argument 'indices' (position 1) must be tuple of Tensors, not Tensor in proposal_target_layer_cascade.py · Issue #242 · jwyang/faster-rcnn.pytorch