parameters: (path, backend=None)
docstring: Load an image.
  
      Args:
          path (str): Path of the image.
          backend (str, optional): The image decoding backend type. Options are
              `cv2`, `pil`, `None`. If backend is None, the global _imread_backend 
              specified by ``paddle.vision.set_image_backend`` will be used. Default: None.
  
      Returns:
          PIL.Image or np.array: Loaded image.
  
      Examples:
      
          .. code-block:: python
  
              import numpy as np
              from PIL import Image
              from paddle.vision import image_load, set_image_backend
  
              fake_img = Image.fromarray((np.random.random((32, 32, 3)) * 255).astype('uint8'))
  
              path = 'temp.png'
              fake_img.save(path)
  
              set_image_backend('pil')
              
              pil_img = image_load(path).convert('RGB')
  
              # should be PIL.Image.Image
              print(type(pil_img))
  
              # use opencv as backend
              # set_image_backend('cv2')
  
              # np_img = image_load(path)
              # # should get numpy.ndarray
              # print(type(np_img))
docstring_summary: Load an image.
docstring_tokens: Load an image .
function: def image_load(path, backend=None):
      """Load an image.
  
      Args:
          path (str): Path of the image.
          backend (str, optional): The image decoding backend type. Options are
              `cv2`, `pil`, `None`. If backend is None, the global _imread_backend 
              specified by ``paddle.vision.set_image_backend`` will be used. Default: None.
  
      Returns:
          PIL.Image or np.array: Loaded image.
  
      Examples:
      
          .. code-block:: python
  
              import numpy as np
              from PIL import Image
              from paddle.vision import image_load, set_image_backend
  
              fake_img = Image.fromarray((np.random.random((32, 32, 3)) * 255).astype('uint8'))
  
              path = 'temp.png'
              fake_img.save(path)
  
              set_image_backend('pil')
              
              pil_img = image_load(path).convert('RGB')
  
              # should be PIL.Image.Image
              print(type(pil_img))
  
              # use opencv as backend
              # set_image_backend('cv2')
  
              # np_img = image_load(path)
              # # should get numpy.ndarray
              # print(type(np_img))
      
      """
  
      if backend is None:
          backend = _image_backend
      if backend not in ['pil', 'cv2', 'tensor']:
          raise ValueError(
              "Expected backend are one of ['pil', 'cv2', 'tensor'], but got {}"
              .format(backend))
  
      if backend == 'pil':
          return Image.open(path)
      elif backend == 'cv2':
          cv2 = try_import('cv2')
          return cv2.imread(path)
function_tokens: def image_load ( path , backend = None ) : if backend is None : backend = _image_backend if backend not in [ 'pil' , 'cv2' , 'tensor' ] : raise ValueError ( "Expected backend are one of ['pil', 'cv2', 'tensor'], but got {}" . format ( backend ) ) if backend == 'pil' : return Image . open ( path ) elif backend == 'cv2' : cv2 = try_import ( 'cv2' ) return cv2 . imread ( path )