From 06ca8161bcb461a2e33a73c716373df79c90f20c Mon Sep 17 00:00:00 2001 From: RayVik Date: Fri, 28 Apr 2023 02:39:58 +0300 Subject: [PATCH] Update functions.py --- deepface/commons/functions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/deepface/commons/functions.py b/deepface/commons/functions.py index 515ab17..4b0e290 100644 --- a/deepface/commons/functions.py +++ b/deepface/commons/functions.py @@ -103,11 +103,11 @@ def load_image(img): if os.path.isfile(img) is not True: raise ValueError(f"Confirm that {img} exists") - img = open(img, "rb") - chunk = img.read() - chunk_arr = np.frombuffer(chunk, dtype=np.uint8) - img = cv2.imdecode(chunk_arr, cv2.IMREAD_COLOR) - + with open(img, "rb") as img: + chunk = img.read() + chunk_arr = np.frombuffer(chunk, dtype=np.uint8) + img = cv2.imdecode(chunk_arr, cv2.IMREAD_COLOR) + return img