I have created a mean image file using python and saved it into numpy file. I would like to know how I could convert this .npy file into .binaryproto file. I am using this f
You can simply use numpy to creat the .binaryproto and the given caffe io functions
import caffe
#avg_img is your numpy array with the average data
blob = caffe.io.array_to_blobproto( avg_img)
with open( mean.binaryproto, 'wb' ) as f :
f.write( blob.SerializeToString())
Here's an improved version of @Kev1n91's code.
import caffe
import numpy as np
mean_npy = np.load('mean.npy') # Input numpy array
blob = caffe.io.array_to_blobproto(mean_npy)
mean_binproto = 'mean.binaryproto' # Output binaryproto file
with open(mean_binproto, 'wb') as f :
f.write( blob.SerializeToString())