Skip to content

Instantly share code, notes, and snippets.

@mpkuse
Created July 11, 2016 03:29
Show Gist options
  • Save mpkuse/e156e54d20bd2389394e69b0f3df7cf6 to your computer and use it in GitHub Desktop.
Save mpkuse/e156e54d20bd2389394e69b0f3df7cf6 to your computer and use it in GitHub Desktop.
.binaryproto of caffe to numpy array
# Converts the mean.binaryproto (mean image) to a numpy image.
import caffe
import numpy as np
import sys
blob = caffe.proto.caffe_pb2.BlobProto()
data = open('mean.binaryproto' , 'rb' ).read()
blob.ParseFromString(data)
arr = np.array( caffe.io.blobproto_to_array(blob) )
out = arr[0]
np.save( 'mean', out )
im = out.transpose(1,2,0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment