Caffe: How do I make .npy mean file?

Created on 28 Jul 2014  路  1Comment  路  Source: BVLC/caffe

Hi I am wondering how to convert mean image produced by compute_image_mean.bin to a numpy array and then to .npy file.

Most helpful comment

After some other searching I have written this short script in python.

import caffe
import numpy as np
import sys

if len(sys.argv) != 3:
  print "Usage: python convert_protomean.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 )

>All comments

After some other searching I have written this short script in python.

import caffe
import numpy as np
import sys

if len(sys.argv) != 3:
  print "Usage: python convert_protomean.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 )
Was this page helpful?
0 / 5 - 0 ratings