Update functions.py

This commit is contained in:
RayVik 2023-04-28 02:39:58 +03:00 committed by GitHub
parent d3f78558ff
commit 06ca8161bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,10 +103,10 @@ 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