parameters: (binaryproto_fname, output=None)
return_statement: return nd
docstring: Convert caffe mean
  
      Parameters
      ----------
      binaryproto_fname : str
          Filename of the mean
      output : str, optional
          Save the mean into mxnet's format
  
      Returns
      -------
      NDArray
          Mean in ndarray
docstring_summary: Convert caffe mean
docstring_tokens: Convert caffe mean
function: def convert_mean(binaryproto_fname, output=None):
      """Convert caffe mean
  
      Parameters
      ----------
      binaryproto_fname : str
          Filename of the mean
      output : str, optional
          Save the mean into mxnet's format
  
      Returns
      -------
      NDArray
          Mean in ndarray
      """
      mean_blob = caffe_parser.caffe_pb2.BlobProto()
      with open(binaryproto_fname, 'rb') as f:
          mean_blob.ParseFromString(f.read())
  
      img_mean_np = np.array(mean_blob.data)
      img_mean_np = img_mean_np.reshape(
          mean_blob.channels, mean_blob.height, mean_blob.width
      )
      # swap channels from Caffe BGR to RGB
      img_mean_np[[0, 2], :, :] = img_mean_np[[2, 0], :, :]
      nd = mx.nd.array(img_mean_np)
      if output is not None:
          mx.nd.save(output, {"mean_image": nd})
      return nd
function_tokens: def convert_mean ( binaryproto_fname , output = None ) : mean_blob = caffe_parser . caffe_pb2 . BlobProto ( ) with open ( binaryproto_fname , 'rb' ) as f : mean_blob . ParseFromString ( f . read ( ) ) img_mean_np = np . array ( mean_blob . data ) img_mean_np = img_mean_np . reshape ( mean_blob . channels , mean_blob . height , mean_blob . width ) # swap channels from Caffe BGR to RGB img_mean_np [ [ 0 , 2 ] , : , : ] = img_mean_np [ [ 2 , 0 ] , : , : ] nd = mx . nd . array ( img_mean_np ) if output is not None : mx . nd . save ( output , { "mean_image" : nd } ) return nd