From acf6185bf3d5d0ee1a530279ba292632d0a48908 Mon Sep 17 00:00:00 2001 From: Indira Salyahova Date: Tue, 15 Feb 2022 10:18:27 +0300 Subject: [PATCH] Update load image in sample (#10223) --- .../tools/pot/api/samples/object_detection/data_loader.py | 2 +- .../tools/pot/api/samples/segmentation/segmentation_sample.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/pot/openvino/tools/pot/api/samples/object_detection/data_loader.py b/tools/pot/openvino/tools/pot/api/samples/object_detection/data_loader.py index a3e974d227b..0a400fd9919 100644 --- a/tools/pot/openvino/tools/pot/api/samples/object_detection/data_loader.py +++ b/tools/pot/openvino/tools/pot/api/samples/object_detection/data_loader.py @@ -71,7 +71,7 @@ class COCOLoader(DataLoader): def _read_and_preprocess_image(image_path): image = cv2.imread(image_path, cv2.IMREAD_COLOR) image = cv2.resize(image, (640, 640)) - return image.transpose(2, 0, 1) + return image @staticmethod def prepare_bbox(x, y, weight, height): diff --git a/tools/pot/openvino/tools/pot/api/samples/segmentation/segmentation_sample.py b/tools/pot/openvino/tools/pot/api/samples/segmentation/segmentation_sample.py index fe05847afda..0eacbe8937d 100644 --- a/tools/pot/openvino/tools/pot/api/samples/segmentation/segmentation_sample.py +++ b/tools/pot/openvino/tools/pot/api/samples/segmentation/segmentation_sample.py @@ -71,10 +71,10 @@ class VOCSegmentationLoader(DataLoader): # Pad image to destination size image = central_padding(image, self._image_size, self._image_size) - return image.transpose(2, 0, 1) # Change data layout from HWC to CHW + return image def _read_and_preprocess_mask(self, mask_path): - mask = self._read_and_preprocess_image(mask_path).transpose(1, 2, 0) + mask = self._read_and_preprocess_image(mask_path) encoded_mask = np.zeros((mask.shape[0], mask.shape[1]), dtype=np.int16) for label, color in enumerate(_SEGMENTATION_COLORS): encoded_mask[np.where(np.all(mask == color, axis=-1))[:2]] = label