在看代码的时候,看到一行注释:use PIL, to be consistent with evaluation
说是用PIL方法加载,却又看见了BGR这种表述,后面的调用也都是cv2格式:
那我就要看下这里面是怎么实现的了,找到了read_image函数,如下:
def read_image(file_name, format=None):"""Read an image into the given format.Will apply rotation and flipping if the image has such exif information.Args:file_name (str): image file pathformat (str): one of the supported image modes in PIL, or "BGR" or "YUV-BT.601".Returns:image (np.ndarray):an HWC image in the given format, which is 0-255, uint8 forsupported image modes in PIL or "BGR"; float (0-1 for Y) for YUV-BT.601."""with PathManager.open(file_name, "rb") as f:image = Image.open(f)# work around this bug: https://github.com/python-pillow/Pillow/issues/3973image = _apply_exif_orientation(image)return convert_PIL_to_numpy(image, format)
原来是用PIL打开后转成了numpy
做个笔记,以上。