From 7a1cad6aa5ad1576dd4c44cb26416d504890a9e0 Mon Sep 17 00:00:00 2001 From: EvenStrangest Date: Mon, 16 Sep 2024 12:47:22 +0300 Subject: [PATCH] replace cv2.imdecode with cv2.imread for faster operation --- pylabel/importer.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pylabel/importer.py b/pylabel/importer.py index 76595c9..7113ead 100644 --- a/pylabel/importer.py +++ b/pylabel/importer.py @@ -342,11 +342,7 @@ def GetCatNameFromId(cat_id, cat_names): row["img_filename"] = image_filename - imgstream = open(str(image_path), "rb") - imgbytes = bytearray(imgstream.read()) - numpyarray = np.asarray(imgbytes, dtype=np.uint8) - - im = cv2.imdecode(numpyarray, cv2.IMREAD_UNCHANGED) + im = cv2.imread(str(image_path), cv2.IMREAD_UNCHANGED) img_height = im.shape[0] img_width = im.shape[1]