Hi all,
I have trained FRCNN using torchvision.models.detection.fasterrcnn_resnet50_fpn and now I want to use it’s feature extraction layers for something else.
To do so I first printed frcnn.modules() and see that the model has 4 major components:
0) GeneralizedRCNNTransform

BackboneWithFPN
RPN
ROI Heads

I tried first to use both first and second modules but ran into an error this is what I tried:
feature_net = nn.Sequential(*list(frcnn.modules()[:2])
a = torch.rand(4,3,256,256)
out = feature_net(a)

and got the following error:
TypeError: conv2d(): argument 'input' (position 1) must be Tensor, not tuple

After looking at GeneralizedRCNNTransform module I have noticed it just holds some metadata about the model, image mean, image std etc.
so I tried to do the same but with the (1) module only (BackboneWithFPN)
feature_net = nn.Sequential(*list(frcnn.modules()[1])

Then passing a worked fine but when trying to print out.shape  raised the following error:
AttributeError: 'collections.OrderedDict' object has no attribute 'shape'

out isn’t tensor as expected.
How can it be solved?
Thank you in advance