def pil_to_np(x): """Converts from PIL.Image to np float format image""" x = np.asarray(x) if len(x.shape) == 2: x = x[:,:,np.newaxis] return img_as_float(np.asarray(x))