Using 8bit images
This commit is contained in:
@@ -72,8 +72,9 @@ def apply_ultralytics_16bit_tiff_patches(*, force: bool = False) -> None:
|
||||
# logger.info(f"Loading with monkey-patched imread: {filename}")
|
||||
arr = arr.astype(np.float32)
|
||||
arr /= arr.max()
|
||||
arr *= 2**16 - 1
|
||||
arr = arr.astype(np.uint16)
|
||||
arr *= 2**8 - 1
|
||||
arr = arr.astype(np.uint8)
|
||||
# print(arr.shape, arr.dtype, any(np.isnan(arr).flatten()), np.where(np.isnan(arr)), arr.min(), arr.max())
|
||||
return np.ascontiguousarray(arr)
|
||||
|
||||
# logger.info(f"Loading with original imread: {filename}")
|
||||
@@ -105,7 +106,7 @@ def apply_ultralytics_16bit_tiff_patches(*, force: bool = False) -> None:
|
||||
def preprocess_batch_16bit(self, batch: dict) -> dict: # type: ignore[override]
|
||||
# Start from upstream behavior to keep device placement + multiscale identical,
|
||||
# but replace the 255 division with dtype-aware scaling.
|
||||
logger.info(f"Preprocessing batch with monkey-patched preprocess_batch")
|
||||
# logger.info(f"Preprocessing batch with monkey-patched preprocess_batch")
|
||||
for k, v in batch.items():
|
||||
if isinstance(v, torch.Tensor):
|
||||
batch[k] = v.to(self.device, non_blocking=self.device.type == "cuda")
|
||||
|
||||
Reference in New Issue
Block a user