Skip to content

Conversation

@Jiaqi-Lv
Copy link
Collaborator

@Jiaqi-Lv Jiaqi-Lv commented Jan 22, 2026

  • Add KongNet Model
  • Add tests
  • Add example notebook (Nucleus Detector)

Jiaqi-Lv and others added 30 commits November 6, 2025 17:23
@shaneahmed shaneahmed changed the title Add KongNet Model and Example Notebook 📝 Add KongNet Model and Example Notebook Jan 23, 2026
@shaneahmed shaneahmed added the documentation Improvements or additions to documentation label Jan 23, 2026
@shaneahmed shaneahmed added this to the Release v2.0.0 milestone Jan 23, 2026
@Jiaqi-Lv Jiaqi-Lv added the enhancement New feature or request label Jan 26, 2026
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.41%. Comparing base (a10a84b) to head (4b9eb2f).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shaneahmed shaneahmed changed the title 📝 Add KongNet Model and Example Notebook 🆕 Add KongNet Model and Example Notebook Jan 31, 2026
Copilot AI review requested due to automatic review settings February 2, 2026 17:18
Copy link
Contributor

Copilot AI left a 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.

Copilot AI review requested due to automatic review settings February 2, 2026 17:59
Copy link
Contributor

Copilot AI left a 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},
Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +753 to +755
) -> None:
"""Load state dict with support for wrapped models."""
return super().load_state_dict(state_dict["model"], strict, assign)
Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants