-
Notifications
You must be signed in to change notification settings - Fork 102
🆕 Add KongNet Model and Example Notebook #987
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
base: dev-define-engines-abc
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev-define-engines-abc #987 +/- ##
==========================================================
+ Coverage 95.33% 95.41% +0.08%
==========================================================
Files 79 80 +1
Lines 10001 10176 +175
Branches 1290 1303 +13
==========================================================
+ Hits 9534 9709 +175
Misses 431 431
Partials 36 36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…mageAnalytics/tiatoolbox into dev-define-KongNet-model
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds the KongNet model, a multi-head encoder-decoder architecture for nuclei detection and classification in digital pathology images. The model uses an EfficientNetV2-L encoder and includes 6 pretrained variants for different datasets and challenges.
Changes:
- Added KongNet model implementation with support for multiple decoder heads and attention mechanisms
- Refactored SegmentationHead from grandqc.py to utils.py for reusability
- Updated zarr API calls to use the new zarr_array_kwargs parameter
- Added utility functions for attention mechanisms and NMS post-processing
- Added comprehensive test coverage for the new model and utilities
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tiatoolbox/models/architecture/kongnet.py | New file implementing KongNet multi-head nuclei detection model with TimmEncoder, decoder blocks, and post-processing |
| tiatoolbox/models/architecture/utils.py | Added SegmentationHead, AttentionModule, SCSEModule classes and nms_on_detection_maps function; enhanced peak_detection_map_overlap with probability output |
| tiatoolbox/models/architecture/grandqc.py | Refactored to import SegmentationHead from utils instead of local definition |
| tiatoolbox/models/engine/nucleus_detector.py | Updated zarr API call to use zarr_array_kwargs; improved comment clarity (segmentation→tissue masks) |
| tiatoolbox/models/engine/engine_abc.py | Updated zarr API call to use zarr_array_kwargs parameter |
| tiatoolbox/data/pretrained_model.yaml | Added 6 KongNet model configurations for different datasets (CoNIC, PanNuke, MONKEY, PUMA, MIDOG) |
| tests/models/test_arch_utils.py | Added tests for nms_on_detection_maps and AttentionModule |
| tests/models/test_arch_kongnet.py | Added comprehensive test suite for KongNet model components and pretrained configurations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| component=f"{key}/{i}", | ||
| compute=False, | ||
| object_codec=object_codec, | ||
| zarr_array_kwargs={"object_codec": object_codec}, |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The to_zarr call on line 777 also needs to be updated to use the new API. It should be changed from:
task = dask_output.to_zarr(
url=save_path, component=key, compute=False, object_codec=None
)
to:
task = dask_output.to_zarr(
url=save_path, component=key, compute=False, zarr_array_kwargs={"object_codec": None}
)
This is the same API change that was applied to line 790 in this PR.
| ) -> None: | ||
| """Load state dict with support for wrapped models.""" | ||
| return super().load_state_dict(state_dict["model"], strict, assign) |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method has a return type annotation of None but is returning the result of super().load_state_dict(). This is inconsistent. Either remove the return keyword (if the return value is not needed), or change the return type annotation to match PyTorch's load_state_dict which returns _IncompatibleKeys. For consistency with the parent class, consider changing the return type annotation to match or simply not returning the value.
Uh oh!
There was an error while loading. Please reload this page.