def _save_mean(mean, filename):
 if filename.endswith('.binaryproto'):
  blob = caffe_pb2.BlobProto()
  blob.num = 1
  blob.channels = 1
  (blob.height, blob.width) = mean.shape
  blob.data.extend(mean.astype(float).flat)
  with open(filename, 'wb') as outfile:
   outfile.write(blob.SerializeToString())
 elif filename.endswith(('.jpg', '.jpeg', '.png')):
  image = PIL.Image.fromarray(mean)
  image.save(filename)
 else:
  raise ValueError('unrecognized file extension')

def _save_mean ( mean , filename ) : if filename . endswith ( '.binaryproto' ) : blob = caffe_pb2 . BlobProto ( ) blob . num = 1 blob . channels = 1 ( blob . height , blob . width ) = mean . shape blob . data . extend ( mean . astype ( float ) . flat ) with open ( filename , 'wb' ) as outfile : outfile . write ( blob . SerializeToString ( ) ) elif filename . endswith ( ( '.jpg' , '.jpeg' , '.png' ) ) : image = PIL . Image . fromarray ( mean ) image . save ( filename ) else : raise ValueError ( 'unrecognized file extension' )
saves mean to file arguments: mean -- the mean as an np .