def load_img(path, grayscale=False, target_size=None):
 if (pil_image is None):
  raise ImportError('Could not import PIL.Image. The use of `array_to_img` requires PIL.')
 img = pil_image.open(path)
 if grayscale:
  img = img.convert('L')
 else:
  img = img.convert('RGB')
 if target_size:
  img = img.resize((target_size[1], target_size[0]))
 return img

def load_img ( path , grayscale = False , target_size = None ) : if ( pil_image is None ) : raise ImportError ( 'Could not import PIL.Image. The use of `array_to_img` requires PIL.' ) img = pil_image . open ( path ) if grayscale : img = img . convert ( 'L' ) else : img = img . convert ( 'RGB' ) if target_size : img = img . resize ( ( target_size [ 1 ] , target_size [ 0 ] ) ) return img
loads an image into pil format .