From 0e74bbc07d86cbe4bf34eb947cb288bc773ca5eb Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Fri, 12 Nov 2021 22:19:39 +0800 Subject: [PATCH] fix PIL may read image with rotation (#4565) --- ppdet/engine/trainer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ppdet/engine/trainer.py b/ppdet/engine/trainer.py index 068e837bd..2d0348a8f 100644 --- a/ppdet/engine/trainer.py +++ b/ppdet/engine/trainer.py @@ -22,7 +22,7 @@ import copy import time import numpy as np -from PIL import Image +from PIL import Image, ImageOps import paddle import paddle.distributed as dist @@ -527,6 +527,7 @@ class Trainer(object): for i, im_id in enumerate(outs['im_id']): image_path = imid2path[int(im_id)] image = Image.open(image_path).convert('RGB') + image = ImageOps.exif_transpose(image) self.status['original_image'] = np.array(image.copy()) end = start + bbox_num[i] -- GitLab