Created
July 12, 2020 17:44
-
-
Save wcneill/ee1979e5287e22a95cc05c1fabb5e320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_features(model, image): | |
layers = { | |
'0' : 'conv1_1', | |
'5' : 'conv2_1', | |
'10': 'conv3_1', | |
'19': 'conv4_1', | |
'21': 'conv4_2', | |
'28': 'conv5_1' | |
} | |
features = {} | |
x = image | |
for name, layer in vgg._modules.items(): | |
x = layer(x) | |
if name in layers: | |
features[layers[name]] = x | |
return features |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment