From a9d7b15b043f141a4d3374004083bbe12dd65634 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Sun, 28 Apr 2024 11:38:31 +0800 Subject: [PATCH] Fix memory leak problem in augment --- basicsr/data/transforms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/basicsr/data/transforms.py b/basicsr/data/transforms.py index d9bbb5fb7..90b5276f7 100644 --- a/basicsr/data/transforms.py +++ b/basicsr/data/transforms.py @@ -119,19 +119,19 @@ def augment(imgs, hflip=True, rotation=True, flows=None, return_status=False): def _augment(img): if hflip: # horizontal - cv2.flip(img, 1, img) + img = cv2.flip(img, 1) # Using inplace operations may cause memory leak if vflip: # vertical - cv2.flip(img, 0, img) + img = cv2.flip(img, 0) if rot90: img = img.transpose(1, 0, 2) return img def _augment_flow(flow): if hflip: # horizontal - cv2.flip(flow, 1, flow) + flow = cv2.flip(flow, 1) flow[:, :, 0] *= -1 if vflip: # vertical - cv2.flip(flow, 0, flow) + flow = cv2.flip(flow, 0) flow[:, :, 1] *= -1 if rot90: flow = flow.transpose(1, 0, 2)