Adding layers to pretrained model

Hello,

I’m using a fine-tuned FasterRCNN model for detecting 2D bounding boxes on the image. After that I have to estimate the 3D position of those bounding boxes, for that I have more inputs for example the intrinsic camera parameters. What I want to do is adding layers to the pretrained model. If I want to embed the pretrained model into my new model, the return value of that is only the loss values, see here.

Example Code of my model extension

class BoundingBox3DNet(nn.Module):
    def __init__(self, model):
        super(BoundingBox3DNet, self).__init__()

        self.model = model

        self.my_new_layers = nn.Sequential(
            nn.Linear(1000, 100),
            nn.ReLU(),
            nn.Linear(100, 2)
        )

    def forward(self, images, calibs, targets):
        x = self.model(images, targets)

        return x

In the forward pass I get only the loss values instead of the detections which I want as input for my model. Also I want from the FasterRCNN model the feature maps, how can I also do this?

Thanks
edna891