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

πŸ§‘β€πŸ’» Define PatchPredictor #783

Open
wants to merge 125 commits into
base: dev-define-engines-abc
Choose a base branch
from

Conversation

shaneahmed
Copy link
Member

@shaneahmed shaneahmed commented Feb 9, 2024

  • Redesigns PatchPredictor engine using the new EngineABC base class.
  • The WSIs are now processed using the same code as for the processing the patches using WSI based dataloader.
  • The intermediate output is saved as zarr for the WSIs to resolve memory issues.
  • The output of model architectures should now be a dictionary.
  • The output can be specified as AnnotationStore for visualisation using TIAViz.

AbishekRajVG and others added 30 commits November 10, 2023 13:44
shaneahmed added a commit that referenced this pull request Jun 25, 2024
- Logger filters need to be reset at the start of run. This is required if a failed test with logs is run in another pytest.
- This PR fixes [failed tests](https://github.com/TissueImageAnalytics/tiatoolbox/actions/runs/9414105193/job/25932262521) in #783.
tiatoolbox/models/engine/engine_abc.py Outdated Show resolved Hide resolved
tiatoolbox/models/engine/engine_abc.py Show resolved Hide resolved
tiatoolbox/models/engine/patch_predictor.py Outdated Show resolved Hide resolved
tiatoolbox/models/engine/patch_predictor.py Outdated Show resolved Hide resolved
tiatoolbox/models/engine/patch_predictor.py Outdated Show resolved Hide resolved
tiatoolbox/models/engine/patch_predictor.py Outdated Show resolved Hide resolved
@Abdol
Copy link
Collaborator

Abdol commented Jul 3, 2024

Thank you @shaneahmed and toolbox team for committing such a good revamp of PatchPredictor. I left only minor feedback.

Copy link
Collaborator

@measty measty left a comment

Choose a reason for hiding this comment

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

I have done an initial review and commented a few things that need changing.

A few other notes as well: this is awkward to review as some changes are wrapped up in the branch this merges into - some of the issues I have found don't show up in the code changed for this PR cause the actual change is in the dev-update-engine-abc branch.

There will need to be a review of the notebooks before this gets merged, as this will at the very least break the patch-prediction notebook and perhaps others.

Also, is the change of behaviour for a model like "resnet18-kather100k" intentional? previously it would return hard class predictions also, now it does not

tiatoolbox/models/engine/engine_abc.py Show resolved Hide resolved
tiatoolbox/models/engine/engine_abc.py Show resolved Hide resolved
@@ -1203,10 +1203,10 @@ def add_from_dat(


def patch_predictions_as_annotations(
preds: list,
preds: list | np.ndarray,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If preds can be empty list this function wont work. Need to iterate over coords instead which always must be there, and save preds only if they exist. At the moment using patch predictor on a WSI with save_type="AnnotationStore" just saves an empty store

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in this commit 5085035

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is still some issues with how it is being saved.

  1. the correct filename isn't being passed to engine.save_predictions, so the saved .db is just called the default output.db. It is being set in:
    out = {image: save_dir / (str(image.stem) + suffix) for image in self.images}

    but this is not being used anywhere.
  2. The scale_factor is not being set and passed to save_predictions, so the patches are currently saved and can be visualized, but appear wrongly scaled. The scale factor needs to be calculated as model_mpp (from io config) / slide_mpp somewhere in the pipeline and added to kwargs.

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.

None yet

5 participants