Skip to content

Instantly share code, notes, and snippets.

@dalgu90
Created August 27, 2016 14:24
Show Gist options
  • Save dalgu90/7fd265e5419efe71477ca560801d0130 to your computer and use it in GitHub Desktop.
Save dalgu90/7fd265e5419efe71477ca560801d0130 to your computer and use it in GitHub Desktop.
convert from proto mean file to npy file
import sys
CAFFE_ROOT = '../../'
sys.path.insert(0, CAFFE_ROOT + 'python/')
import caffe
import numpy as np
if len(sys.argv) != 3:
print "Usage: python protomean_to_npy.py proto.mean out.npy"
sys.exit()
blob = caffe.proto.caffe_pb2.BlobProto()
data = open( sys.argv[1] , 'rb' ).read()
blob.ParseFromString(data)
arr = np.array( caffe.io.blobproto_to_array(blob) )
out = arr[0]
np.save( sys.argv[2] , out )
@bckim92
Copy link

bckim92 commented Oct 31, 2016

Thank you! Kaiming He!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment