Index error using custom backbone on FasterRCNN

I got the same error following the tutorial exactly, but the FasterRCNN documentation:

https://github.com/pytorch/vision/blob/master/torchvision/models/detection/faster_rcnn.py

suggests that the featmap_names in the MultiScaleROIAlign should be a character, ‘0’, not an integer. I replaced

roi_pooler = torchvision.ops.MultiScaleRoIAlign(featmap_names=[0],
                                                output_size=7,
                                                sampling_ratio=2)

with

roi_pooler = torchvision.ops.MultiScaleRoIAlign(featmap_names=['0'],
                                                output_size=7,
                                                sampling_ratio=2)

and the error on foward pass went away. I haven’t verified that the model finetunes appropriately though.

Hope this helps.