Open gpmarques opened 3 years ago
I'm not sure if I follow you fully. Do mean a way to load models without heads heads? (i.e, only stems and backbone)
Yes, that would work. Because nowadays if I load a pre-trained model, how can I get the output from intermediate layers?
you can just access the model final block by model.blocks[-1]
, depending on the network type you can change the number of output features or the entire block. For my use case I only changed the projection layer which is basically the number of output features:
model_name = "slow_r50"
model = torch.hub.load("facebookresearch/pytorchvideo", model=model_name, pretrained=True)
model.blocks[-1].proj = nn.Linear(2048, 10)
@gpmarques , we are also working on an API update for models which would allow you to not load head and get the intermediate features from the backbone.
@danikv ooh, ok I get it! Thanks.
@kalyanvasudev that's great to know! Thanks for the support.
🚀 Feature
It would be great if the models API had an easy way to instantiate a model with the purpose of feature extraction!
Meanwhile, is there any workaround?