Skip to content

Instantly share code, notes, and snippets.

@adriacabeza
Created October 23, 2020 08:35
Show Gist options
  • Select an option

  • Save adriacabeza/aa4e2e4791fda322cd159e24518f02a4 to your computer and use it in GitHub Desktop.

Select an option

Save adriacabeza/aa4e2e4791fda322cd159e24518f02a4 to your computer and use it in GitHub Desktop.

Revisions

  1. adriacabeza created this gist Oct 23, 2020.
    13 changes: 13 additions & 0 deletions get_layers_caffe.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    import caffe

    import numpy as np

    mean = np.load('mean.npy').mean(1).mean(1)
    image_dims = (224, 244)
    model = 'deploy.prototxt'
    weights = 'resnet-50.caffemodel'

    net = caffe.Classifier(model, weights, image_dims=image_dims, mean=mean, raw_scale=255, channel_swap=[2, 1, 0])
    nb = net.blobs
    for ctr, name in enumerate(nb):
    print(ctr, name, nb[name].data.shape)