diff --git a/giskard_vision/core/dataloaders/base.py b/giskard_vision/core/dataloaders/base.py index 99bf22b6..f581b104 100644 --- a/giskard_vision/core/dataloaders/base.py +++ b/giskard_vision/core/dataloaders/base.py @@ -145,7 +145,11 @@ def get_meta(self, idx: int) -> Optional[TypesBase.meta]: Optional[TypesBase.meta]: Meta information for the given index. """ img = self.get_image(idx) - gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + if img.dtype != np.uint8: + # Normalize image to 0-255 range with uint8 + img = (img * 255 % 255).astype(np.uint8) + + gray_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) size = get_image_size(img) nb_channels = get_image_channel_number(img) avg_color = np.mean(img, axis=(0, 1)) diff --git a/giskard_vision/core/dataloaders/meta.py b/giskard_vision/core/dataloaders/meta.py index dfabe672..93c06c14 100644 --- a/giskard_vision/core/dataloaders/meta.py +++ b/giskard_vision/core/dataloaders/meta.py @@ -219,7 +219,7 @@ def get_brightness(image: np.ndarray) -> float: Returns: float: The image brightness normalized to 1. """ - hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) + hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV) return np.mean(hsv[:, :, 2]) / 255