image_load¶
- paddle.vision. image_load ( path, backend=None ) [source]
- 
         Load an image. - Parameters
- 
           - 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_backendwill be used. Default: None.
 
- Returns
- 
           Loaded image. 
- Return type
- 
           PIL.Image or np.array 
 Examples 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)) 
