-
Notifications
You must be signed in to change notification settings - Fork 102
NEW: Add SCCNN Cell Detection Architecture #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 4606025
DOC: Add docs to SCCNN architecture.
shaneahmed 5b6d58a
NEW: Add preproc function to sccnn.py.
shaneahmed 106deec
NEW: Add infer_batch function to sccnn.py.
shaneahmed 290e2ae
NEW: Add postproc function to sccnn.py.
shaneahmed e28252b
TST: Add tests for sccnn.py.
shaneahmed 64bb155
REF: Code refactoring
shaneahmed e0f6079
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c5b29c7
DOC: Fix docstring
shaneahmed a4a2b5b
Merge remote-tracking branch 'origin/feature-sccnn-detection' into fe…
shaneahmed 8abe76f
MAINT: Remove redundant function
shaneahmed 90b9a28
DOC: Update documentation.
shaneahmed 9686ea2
MAINT: Update model.
shaneahmed 7b970aa
Merge remote-tracking branch 'origin/feature-sccnn-detection' into fe…
shaneahmed 051c68a
DOC: Fix docstring.
shaneahmed f6ec820
Merge branch 'develop' into feature-sccnn-detection
shaneahmed d21ec04
Merge branch 'develop' into feature-sccnn-detection
shaneahmed 6dcf873
REF: Refactor functions to meaningful names.
shaneahmed 0b7bd23
REF: Refactor variables to meaningful names.
shaneahmed d720eea
TST: Update model and test
shaneahmed d8df962
MAINT: Future proofing
shaneahmed dd981ec
MAINT: Future proofing
shaneahmed 994dff4
REF: Refactor conv_act_branch
shaneahmed 0a1ea92
BUG: torch.arange has different behaviour
shaneahmed fce8fd5
MAINT: Change default parameters.
shaneahmed 3ab3362
MAINT: Remove redundant conv_act_branch function.
shaneahmed b24422f
DEV: Use register_buffer for xv and yv.
shaneahmed 4d6adcd
MAINT: Move `spatially_constrained_layer2` outside forward function.
shaneahmed 3c14bfd
DEV: Define post processing variables.
shaneahmed 5dbd393
NEW: Add conic model
shaneahmed a87355b
Merge branch 'develop' into feature-sccnn-detection
shaneahmed 2041de3
NEW: Update CoNiC model
shaneahmed 906d751
DOC: Adds information for tests in docstring.
shaneahmed b30c6eb
DOC: Fixing type hint, docstring, and formatting.
shaneahmed 5314e10
BUG: Fix G200 Logging statement uses exception.
shaneahmed cc45655
BUG: Fix Unsupported operand |.
shaneahmed 761ee10
Merge branch 'develop' into feature-sccnn-detection
shaneahmed c7facb7
DOC: Update sccnn-conic
shaneahmed 33b5ae1
DOC: Fix docstring.
shaneahmed 84be6c1
DOC: Fix sccnn docstring.
shaneahmed fa05564
Update tiatoolbox/models/architecture/sccnn.py
shaneahmed 4b643c1
Merge branch 'develop' into feature-sccnn-detection
shaneahmed fa627ec
Merge branch 'develop' into feature-sccnn-detection
shaneahmed 2df5677
Merge branch 'develop' into feature-sccnn-detection
shaneahmed f9918ca
Merge branch 'develop' into feature-sccnn-detection
shaneahmed 2bb6a72
DOC: Add SCCNN to usage.rst.
shaneahmed dff09b0
DEV: Use self._transform for converting image to float.
shaneahmed 3ef7ab3
Merge branch 'develop' into feature-sccnn-detection
shaneahmed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.