diff --git a/tests/models/test_arch_sccnn.py b/tests/models/test_arch_sccnn.py index 2629304af..a456faff5 100644 --- a/tests/models/test_arch_sccnn.py +++ b/tests/models/test_arch_sccnn.py @@ -39,15 +39,17 @@ def test_functionality(remote_sample: Callable) -> None: units="mpp", coord_space="resolution", ) - batch = torch.from_numpy(patch)[None] model = _load_sccnn(name="sccnn-crchisto") + patch = model.preproc(patch) + batch = torch.from_numpy(patch)[None] output = model.infer_batch( model, batch, device=select_device(on_gpu=env_detection.has_gpu()), ) output = model.postproc(output[0]) - assert np.all(output == [[8, 7]]) + np.testing.assert_array_equal(output, np.array([[8, 7]])) + model = _load_sccnn(name="sccnn-conic") output = model.infer_batch( model, @@ -55,4 +57,4 @@ def test_functionality(remote_sample: Callable) -> None: device=select_device(on_gpu=env_detection.has_gpu()), ) output = model.postproc(output[0]) - assert np.all(output == [[7, 8]]) + np.testing.assert_array_equal(output, np.array([[7, 8]])) diff --git a/tiatoolbox/data/pretrained_model.yaml b/tiatoolbox/data/pretrained_model.yaml index 19ce8f45d..05f3d16f5 100644 --- a/tiatoolbox/data/pretrained_model.yaml +++ b/tiatoolbox/data/pretrained_model.yaml @@ -863,14 +863,14 @@ sccnn-crchisto: class: semantic_segmentor.IOSegmentorConfig kwargs: input_resolutions: - - { "units": "mpp", "resolution": 0.5 } + - { "units": "mpp", "resolution": 0.25 } output_resolutions: - - { "units": "mpp", "resolution": 0.5 } + - { "units": "mpp", "resolution": 0.25 } tile_shape: [ 2048, 2048 ] patch_input_shape: [ 31, 31 ] patch_output_shape: [ 13, 13 ] stride_shape: [ 8, 8 ] - save_resolution: { 'units': 'mpp', 'resolution': 0.5 } + save_resolution: { 'units': 'mpp', 'resolution': 0.25 } sccnn-conic: hf_repo_id: TIACentre/TIAToolbox_pretrained_weights @@ -886,14 +886,14 @@ sccnn-conic: class: semantic_segmentor.IOSegmentorConfig kwargs: input_resolutions: - - { "units": "mpp", "resolution": 0.5 } + - { "units": "mpp", "resolution": 0.25 } output_resolutions: - - { "units": "mpp", "resolution": 0.5 } + - { "units": "mpp", "resolution": 0.25 } tile_shape: [ 2048, 2048 ] patch_input_shape: [ 31, 31 ] patch_output_shape: [ 13, 13 ] stride_shape: [ 8, 8 ] - save_resolution: { 'units': 'mpp', 'resolution': 0.5 } + save_resolution: { 'units': 'mpp', 'resolution': 0.25 } nuclick_original-pannuke: hf_repo_id: TIACentre/TIAToolbox_pretrained_weights diff --git a/tiatoolbox/models/architecture/sccnn.py b/tiatoolbox/models/architecture/sccnn.py index 4da0f9dca..2c47f9d12 100644 --- a/tiatoolbox/models/architecture/sccnn.py +++ b/tiatoolbox/models/architecture/sccnn.py @@ -239,7 +239,7 @@ def spatially_constrained_layer2( return sc2 * out_map_threshold @staticmethod - def preproc(image: torch.Tensor) -> torch.Tensor: + def preproc(image: np.ndarray) -> np.ndarray: """Transforming network input to desired format. This method is model and dataset specific, meaning that it can be replaced by @@ -309,7 +309,6 @@ def spatially_constrained_layer1( sigmoid2 = sigmoid[:, 2:3, :, :] return sigmoid0, sigmoid1, sigmoid2 - input_tensor = self.preproc(input_tensor) l1 = self.layer["l1"]["conv1"](input_tensor) p1 = self.layer["pool1"](l1) l2 = self.layer["l2"]["conv1"](p1)