def prepare(image, size=(224, 224)):
 if (not available):
  raise ImportError(('PIL cannot be loaded. Install Pillow!\nThe actual import error is as follows:\n' + str(_import_error)))
 if isinstance(image, numpy.ndarray):
  if (image.ndim == 3):
   if (image.shape[0] == 1):
    image = image[0, :, :]
   elif (image.shape[0] == 3):
    image = image.transpose((1, 2, 0))
  image = Image.fromarray(image.astype(numpy.uint8))
 image = image.convert('RGB')
 if size:
  image = image.resize(size)
 image = numpy.asarray(image, dtype=numpy.float32)
 image = image[:, :, ::(-1)]
 image -= numpy.array([103.939, 116.779, 123.68], dtype=numpy.float32)
 image = image.transpose((2, 0, 1))
 return image

def prepare ( image , size = ( 224 , 224 ) ) : if ( not available ) : raise ImportError ( ( 'PIL cannot be loaded. Install Pillow!\nThe actual import error is as follows:\n' + str ( _import_error ) ) ) if isinstance ( image , numpy . ndarray ) : if ( image . ndim == 3 ) : if ( image . shape [ 0 ] == 1 ) : image = image [ 0 , : , : ] elif ( image . shape [ 0 ] == 3 ) : image = image . transpose ( ( 1 , 2 , 0 ) ) image = Image . fromarray ( image . astype ( numpy . uint8 ) ) image = image . convert ( 'RGB' ) if size : image = image . resize ( size ) image = numpy . asarray ( image , dtype = numpy . float32 ) image = image [ : , : , : : ( - 1 ) ] image -= numpy . array ( [ 103.939 , 116.779 , 123.68 ] , dtype = numpy . float32 ) image = image . transpose ( ( 2 , 0 , 1 ) ) return image
try to get current process ready to unpickle process object .