本文主要是介绍将binaryproto文件转换为npy文件 代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
将binaryproto文件转换为npy文件 代码
(2016-05-09 10:12:44)
分类: 代码分享 |
import caffe
import os
import numpy as np
print "Usage: python convert_protomean.py proto.mean out.npy"
blob = caffe.proto.caffe_pb2.BlobProto()
BINARY_PROTO_FILE_NAME ='./model/mean.binaryproto'
BINARY_PROTO_FILE_PATH = os.path.join(os.getcwd(),BINARY_PROTO_FILE_NAME)
NPY_FILE_NAME ='./model/image_mean.npy'
NPY_FILE_PATH = os.path.join(os.getcwd(),NPY_FILE_NAME)
data = open( BINARY_PROTO_FILE_PATH, 'rb' ).read()
blob.ParseFromString(data)
arr = np.array( caffe.io.blobproto_to_array(blob) )
out = arr[0]
np.save( NPY_FILE_PATH , out )
import os
import numpy as np
print "Usage: python convert_protomean.py proto.mean out.npy"
blob = caffe.proto.caffe_pb2.BlobProto()
BINARY_PROTO_FILE_NAME
BINARY_PROTO_FILE_PATH
NPY_FILE_NAME
NPY_FILE_PATH
data = open( BINARY_PROTO_FILE_PATH, 'rb' ).read()
blob.ParseFromString(data)
arr = np.array( caffe.io.blobproto_to_array(blob) )
out = arr[0]
np.save( NPY_FILE_PATH , out )
这篇关于将binaryproto文件转换为npy文件 代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!