Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
627b68c
NEW: Add SCCNN architecture.
shaneahmed Jul 27, 2022
4606025
DOC: Add docs to SCCNN architecture.
shaneahmed Jul 27, 2022
5b6d58a
NEW: Add preproc function to sccnn.py.
shaneahmed Jul 27, 2022
106deec
NEW: Add infer_batch function to sccnn.py.
shaneahmed Jul 27, 2022
290e2ae
NEW: Add postproc function to sccnn.py.
shaneahmed Jul 27, 2022
e28252b
TST: Add tests for sccnn.py.
shaneahmed Jul 27, 2022
64bb155
REF: Code refactoring
shaneahmed Jul 27, 2022
e0f6079
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2022
c5b29c7
DOC: Fix docstring
shaneahmed Jul 27, 2022
a4a2b5b
Merge remote-tracking branch 'origin/feature-sccnn-detection' into fe…
shaneahmed Jul 27, 2022
8abe76f
MAINT: Remove redundant function
shaneahmed Jul 28, 2022
90b9a28
DOC: Update documentation.
shaneahmed Jul 28, 2022
9686ea2
MAINT: Update model.
shaneahmed Jul 28, 2022
7b970aa
Merge remote-tracking branch 'origin/feature-sccnn-detection' into fe…
shaneahmed Jul 28, 2022
051c68a
DOC: Fix docstring.
shaneahmed Jul 28, 2022
f6ec820
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Jul 28, 2022
d21ec04
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Jul 28, 2022
6dcf873
REF: Refactor functions to meaningful names.
shaneahmed Jul 29, 2022
0b7bd23
REF: Refactor variables to meaningful names.
shaneahmed Jul 29, 2022
d720eea
TST: Update model and test
shaneahmed Aug 2, 2022
d8df962
MAINT: Future proofing
shaneahmed Aug 5, 2022
dd981ec
MAINT: Future proofing
shaneahmed Aug 5, 2022
994dff4
REF: Refactor conv_act_branch
shaneahmed Aug 5, 2022
0a1ea92
BUG: torch.arange has different behaviour
shaneahmed Aug 5, 2022
fce8fd5
MAINT: Change default parameters.
shaneahmed Aug 5, 2022
3ab3362
MAINT: Remove redundant conv_act_branch function.
shaneahmed Aug 5, 2022
b24422f
DEV: Use register_buffer for xv and yv.
shaneahmed Aug 5, 2022
4d6adcd
MAINT: Move `spatially_constrained_layer2` outside forward function.
shaneahmed Aug 5, 2022
3c14bfd
DEV: Define post processing variables.
shaneahmed Aug 5, 2022
5dbd393
NEW: Add conic model
shaneahmed Aug 9, 2022
a87355b
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Aug 9, 2022
2041de3
NEW: Update CoNiC model
shaneahmed Aug 10, 2022
906d751
DOC: Adds information for tests in docstring.
shaneahmed Aug 12, 2022
b30c6eb
DOC: Fixing type hint, docstring, and formatting.
shaneahmed Aug 12, 2022
5314e10
BUG: Fix G200 Logging statement uses exception.
shaneahmed Aug 12, 2022
cc45655
BUG: Fix Unsupported operand |.
shaneahmed Aug 12, 2022
761ee10
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Aug 15, 2022
c7facb7
DOC: Update sccnn-conic
shaneahmed Aug 15, 2022
33b5ae1
DOC: Fix docstring.
shaneahmed Aug 16, 2022
84be6c1
DOC: Fix sccnn docstring.
shaneahmed Aug 17, 2022
fa05564
Update tiatoolbox/models/architecture/sccnn.py
shaneahmed Aug 17, 2022
4b643c1
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Aug 22, 2022
fa627ec
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Aug 24, 2022
2df5677
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Aug 26, 2022
f9918ca
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Aug 30, 2022
2bb6a72
DOC: Add SCCNN to usage.rst.
shaneahmed Aug 31, 2022
dff09b0
DEV: Use self._transform for converting image to float.
shaneahmed Sep 1, 2022
3ef7ab3
Merge branch 'develop' into feature-sccnn-detection
shaneahmed Sep 1, 2022
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
2 changes: 1 addition & 1 deletion tests/models/test_arch_micronet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# skipcq: PTC-W6004
"""Unit test package for HoVerNet."""
"""Unit test package for MicroNet."""

import pathlib

Expand Down
46 changes: 46 additions & 0 deletions tests/models/test_arch_sccnn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Unit test package for SCCNN."""
import numpy as np
import torch

from tiatoolbox import utils
from tiatoolbox.models.architecture import fetch_pretrained_weights
from tiatoolbox.models.architecture.sccnn import SCCNN
from tiatoolbox.wsicore.wsireader import WSIReader


def _load_sccnn(tmp_path, name):
"""Loads SCCNN model with specified weights."""
model = SCCNN()
fetch_pretrained_weights(name, f"{tmp_path}/weights.pth")
map_location = utils.misc.select_device(utils.env_detection.has_gpu())
pretrained = torch.load(f"{tmp_path}/weights.pth", map_location=map_location)
model.load_state_dict(pretrained)

return model


def test_functionality(remote_sample, tmp_path):
"""Functionality test for SCCNN.

Tests the functionality of SCCNN model for inference at the patch level.

"""
tmp_path = str(tmp_path)
sample_wsi = str(remote_sample("wsi1_2k_2k_svs"))
reader = WSIReader.open(sample_wsi)

# * test fast mode (architecture used in PanNuke paper)
patch = reader.read_bounds(
(30, 30, 61, 61), resolution=0.25, units="mpp", coord_space="resolution"
)
patch = SCCNN.preproc(patch)
batch = torch.from_numpy(patch)[None]
model = _load_sccnn(tmp_path=tmp_path, name="sccnn-crchisto")
output = model.infer_batch(model, batch, on_gpu=False)
output = model.postproc(output[0])
assert np.all(output == [[8, 7]])

model = _load_sccnn(tmp_path=tmp_path, name="sccnn-conic")
output = model.infer_batch(model, batch, on_gpu=False)
output = model.postproc(output[0])
assert np.all(output == [[7, 8]])
24 changes: 24 additions & 0 deletions tiatoolbox/data/pretrained_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,27 @@ micronet-consep:
patch_output_shape: [252, 252]
stride_shape: [150, 150]
save_resolution: {'units': 'mpp', 'resolution': 0.25}

sccnn-crchisto:
url: https://tiatoolbox.dcs.warwick.ac.uk/models/detection/sccnn-crchisto.pth
architecture:
class: sccnn.SCCNN
kwargs:
num_input_channels: 3
out_height: 13
out_width: 13
radius: 12
min_distance: 6
threshold_abs: 0.20

sccnn-conic:
url: https://tiatoolbox.dcs.warwick.ac.uk/models/detection/sccnn-conic.pth
architecture:
class: sccnn.SCCNN
kwargs:
num_input_channels: 3
out_height: 13
out_width: 13
radius: 12
min_distance: 5
threshold_abs: 0.05
3 changes: 2 additions & 1 deletion tiatoolbox/models/architecture/micronet.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,10 @@ def out_arch_branch(in_ch, num_class=2):


class MicroNet(ModelABC):
"""Initialise MicroNet [1].
"""Initialize MicroNet [1].

The following models have been included in tiatoolbox:

1. `micronet-consep`:
This is trained on `CoNSeP dataset
<https://warwick.ac.uk/fac/cross_fac/tia/data/hovernet/>`_ The
Expand Down
Loading