def uint_to_img(uint_img, mean_img=None):
  """
  Do pre-processing to convert images from a normal format to caffe format.
  """
  img = uint_img.astype('float')
  img = img[:, :, [2, 1, 0]]
  img = img.transpose(2, 0, 1)
  img = img[np.newaxis, :, :, :]
  if mean_img is not None:
    img = img - mean_img.mean()
  return img

  Do pre-processing to convert images from a normal format to caffe format.
  
cnn_vis.py