Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/models/test_arch_sccnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ 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,
batch,
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]]))
12 changes: 6 additions & 6 deletions tiatoolbox/data/pretrained_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tiatoolbox/models/architecture/sccnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading