Skip to content
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

✨ Add PatchPredictor Engine #865

Merged
merged 48 commits into from
Nov 20, 2024

Conversation

shaneahmed
Copy link
Member

@shaneahmed shaneahmed commented Sep 20, 2024

  • Add PatchPredictor Engine based on EngineABC
  • Add return_probabilities option to Params
  • Removes merge_predictions option in PatchPredictor engine.
  • Defines post_process_cache_mode which allows running the algorithm on WSI
  • Add infer_wsi for WSI inference
  • Removes save_wsi_output as this is not required after post processing.
  • Removes merge_predictions and fixes docstring in EngineABCRunParams
  • compile_model is now moved to EngineABC init
  • Fixes bug with _calculate_scale_factor
  • Fixes a bug in class_dict definition.
  • _get_zarr_array is now a public function get_zarr_array in misc
  • patch_predictions_as_annotations runs the loop on patch_coords instead of class_probs

@shaneahmed shaneahmed added the enhancement New feature or request label Sep 20, 2024
@shaneahmed shaneahmed self-assigned this Sep 20, 2024
@shaneahmed shaneahmed added this to the Release v2.0.0 milestone Sep 20, 2024
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.47%. Comparing base (dba269c) to head (156179d).
Report is 1 commits behind head on dev-define-engines-abc.

Additional details and impacted files
@@                    Coverage Diff                     @@
##           dev-define-engines-abc     #865      +/-   ##
==========================================================
+ Coverage                   91.34%   91.47%   +0.13%     
==========================================================
  Files                          71       71              
  Lines                        8892     8920      +28     
  Branches                     1180     1185       +5     
==========================================================
+ Hits                         8122     8160      +38     
+ Misses                        751      744       -7     
+ Partials                       19       16       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@shaneahmed shaneahmed changed the title ✨ Add PatchClassificatier Engine ✨ Add PatchClassificaier Engine Sep 24, 2024
@shaneahmed shaneahmed changed the title ✨ Add PatchClassificaier Engine ✨ Add PatchClassifier Engine Sep 24, 2024
@shaneahmed
Copy link
Member Author

I left a couple of specific comments, but also a general comment - there seems to be a lot of duplication of code/docstrings/text in general, with PatchPredictor mostly just calling the superclass with all of its methods apart from 1. It is a ~500 line file which is almost functionally equivalent to the EngineABC class apart from infer_wsi() method. The proliferation of the amount of text you need to go through in various files to get down to where the actual things are being done/identify what is the key difference a specific subclass introduces, is something we should try to avoid, in my opinion.

Thanks @measty. I have removed duplicated code as well.

Copy link
Collaborator

@mostafajahanifar mostafajahanifar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Shan for doing this PR. All looks good to me. I only made a couple of minor comments.

However, I also have a question: I don't understand the reason for needing "PatchPredictor" class to serve "PatchClassifer" as a parent class. Would be great if you can let me know why you have decided to do it like this (you most probably have discussed it before, but I'm very forgetful, I'm sorry :-s).

tiatoolbox/models/engine/patch_classifier.py Outdated Show resolved Hide resolved
tiatoolbox/models/engine/patch_predictor.py Show resolved Hide resolved
@shaneahmed
Copy link
Member Author

Thanks Shan for doing this PR. All looks good to me. I only made a couple of minor comments.

However, I also have a question: I don't understand the reason for needing "PatchPredictor" class to serve "PatchClassifer" as a parent class. Would be great if you can let me know why you have decided to do it like this (you most probably have discussed it before, but I'm very forgetful, I'm sorry :-s).

Thanks @mostafajahanifar. This was a suggestion by Fayyaz to separate the two. In some cases, we do not need classification. For example, in semantic segmentor we need the raw predictions which are then converted to segmentation. In other cases, where we are building a pipeline where we need raw predictions instead of classification, this can simplify the pipeline by using just the predictor.

@shaneahmed shaneahmed changed the title ✨ Add PatchClassifier Engine ✨ Add PatchPredictor Engine Nov 17, 2024
@shaneahmed shaneahmed merged commit 1fccf15 into dev-define-engines-abc Nov 20, 2024
15 checks passed
@shaneahmed shaneahmed deleted the dev-define-patch-classification branch November 20, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants