diff --git a/src/utils/image.py b/src/utils/image.py index e0d3991..088b0ff 100644 --- a/src/utils/image.py +++ b/src/utils/image.py @@ -121,7 +121,7 @@ class Image: if self.path.suffix.lower() in [".tif", ".tiff"]: self._data = imread(str(self.path)) else: - raise NotImplementedError + raise NotImplementedError("RGB is not implemented") # Load with OpenCV (returns BGR format) self._data = cv2.imread(str(self.path), cv2.IMREAD_UNCHANGED) @@ -129,7 +129,7 @@ class Image: raise ImageLoadError(f"Failed to load image with OpenCV: {self.path}") # Extract metadata - print(self._data.shape) + # print(self._data.shape) if len(self._data.shape) == 2: self._height, self._width = self._data.shape[:2] self._channels = 1 diff --git a/src/utils/ultralytics_16bit_patch.py b/src/utils/ultralytics_16bit_patch.py index 72d60d8..462017f 100644 --- a/src/utils/ultralytics_16bit_patch.py +++ b/src/utils/ultralytics_16bit_patch.py @@ -54,7 +54,8 @@ def apply_ultralytics_16bit_tiff_patches(*, force: bool = False) -> None: - For other formats, falls back to Ultralytics' original implementation. - Always returns HWC (3 dims). For grayscale, returns (H, W, 1) or (H, W, 3) depending on requested flags. """ - + # print("here") + # return _original_imread(filename, flags) ext = os.path.splitext(filename)[1].lower() if ext in (".tif", ".tiff"): arr = Image(filename).get_qt_rgb()[:, :, :3] @@ -75,6 +76,7 @@ def apply_ultralytics_16bit_tiff_patches(*, force: bool = False) -> None: # Ensure contiguous array for downstream OpenCV ops. # logger.info(f"Loading with monkey-patched imread: {filename}") + arr *= (2**16 - 1).astype(np.uint16) return np.ascontiguousarray(arr) # logger.info(f"Loading with original imread: {filename}")