BartolomeD:

model = densenet121(pretrained=True)
class FeatureExtractor(nn.Module):
def init(self):
super(FeatureExtractor, self).init()
self.features = nn.Sequential(*list(model.features.children()))
def forward(self, x):
x = self.features(x)
return x
model_features = FeatureExtractor()


Thanks a lot! It works!