14 Read an image into the given format.
15 Will apply rotation and flipping if the image has such exif information.
17 file_name (str): image file path
18 format (str): one of the supported image modes in PIL, or "BGR"
20 image (np.ndarray): an HWC image
22 with PathManager.open(file_name,
"rb")
as f:
27 image = ImageOps.exif_transpose(image)
31 if format
is not None:
33 conversion_format = format
35 conversion_format =
"RGB"
36 image = image.convert(conversion_format)
37 image = np.asarray(image)
40 image = image[:, :, ::-1]
43 image = np.expand_dims(image, -1)
44 image = Image.fromarray(image)