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.
Get layers and shape of a Caffe model
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment