main.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:deepstacks 作者: guoxuesong 项目源码 文件源码
def load_mean_file(mean_file):
        if mean_file.endswith('.npy'):
            return np.load(mean_file)
        with open(mean_file, 'rb') as infile:
            blob = caffe_pb2.BlobProto()
            blob.MergeFromString(infile.read())
            if blob.HasField('shape'):
                blob_dims = blob.shape
                assert len(blob_dims) == 4, 'Shape should have 4 dimensions - shape is "%s"' % blob.shape
            elif blob.HasField('num') and blob.HasField('channels') and \
                    blob.HasField('height') and blob.HasField('width'):
                blob_dims = (blob.num, blob.channels, blob.height, blob.width)
            else:
                raise ValueError('blob does not provide shape or 4d dimensions')
            #pixel = np.reshape(blob.data, blob_dims[1:]).mean(1).mean(1)
            #print pixel.shape
            #t.set_mean('data', pixel)
            mean=np.reshape(blob.data, blob_dims[1:])
            #mean=mean[:,(256-224)//2:(256-224)//2+224,(256-224)//2:(256-224)//2+224]
        return mean
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号