Граф коммитов

64 Коммитов

Автор SHA1 Сообщение Дата
Kenza Bouzid 5c09c280a8
ENH: Add diagnosis for Tiff Conversion (#862) 2023-03-31 15:10:16 +01:00
Peter Hessey 6f0cff82d6 ♻️ Style and fix mypy 2023-03-23 15:06:19 +00:00
Peter Hessey c7c5b03a74 💄 Add black styling and configuration
MNT: Fix incorrect type annotations (#846)

ENH: Refactor Swin Transformer checkpointing (#843)

Refactor Swin Transformer checkpointing to enable patch embedding
checkpointing overriding without duplication the whole custom forward

MNT: Fix incorrect type annotations (#846)

ENH: Refactor Swin Transformer checkpointing (#843)

Refactor Swin Transformer checkpointing to enable patch embedding
checkpointing overriding without duplication the whole custom forward

Add multi-modal to root makefile

🐛 Fix Makefile updates

📝 Update dev documentation

🔧 Add pyproject.toml

👷 Update makefiles to use black config

📝 Add VS Code + black docs

🔧 Update settings.json for all repos
2023-03-23 14:32:03 +00:00
Kenza Bouzid 97b9bae3d1
ENH: Enable activation checkpointing for Resnet and SwinTransformer (#842)
Add custom forward that checkpoints activations to trade compute for
memory

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-03-17 11:54:49 +00:00
Kenza Bouzid 273e84e6bb
ENH: Add non normalized confusion matrix to plot options (#791)
Add non normalized confusion matrix to plot options
2023-03-14 13:31:45 +00:00
Kenza Bouzid 14b43222de
BUG: Convert to tifffile if file doesn't exist or if it's empty (#836)
Fix issue of 0 bytes files
2023-03-13 16:10:50 +00:00
Kenza Bouzid 1fa499b00d
MNT: Upgrade pytorch to 1.11 (#833)
Upgrade pytorch to 1.11
Add static graph flag
2023-03-10 11:01:59 +00:00
Kenza Bouzid cb97c59912
ENH: Add LoadMaskSubROId transform (#828)
LoadMaskSubROId loads a sub section from a slide based a foreground png
mask with categorical labels for each tissue section.

---------

Co-authored-by: Anton Schwaighofer <antonsc@microsoft.com>
2023-03-07 13:42:43 +00:00
Kenza Bouzid ea2ad93780
ENH: Enable flexible resolution unit for mock data generator (#827)
Add resolution_unit param to Mock slides generator
2023-03-06 15:10:38 +00:00
Kenza Bouzid 191d041b4e
ENH: WSI Conversion to tiff files (#820)
- Add ConvertWSIToTiffd transform 
- Add TiffConversionConfig for running on a slides dataset
- unit tests
2023-03-02 16:35:27 +00:00
Anton Schwaighofer a4fe5e4353
MNT: Upgrade pytest (#813)
Upgrade to Pytest 7 and remove the manual setting of `sys.path` in
`conftest.py`
Upgrade mypy and flake8
2023-02-23 14:31:15 +00:00
Harshita Sharma 5ce9e00fd5
ENH: Add background normalization transform (#803)
In this PR, background normalization transform is added and
corresponding tests are also added.
2023-02-22 12:28:02 +00:00
Kenza Bouzid efd08fd408
ENH: Add Swin Transformer Encoder and Projection layer (#810)
Add Swin transformer encoder and an intermediate projection layer
2023-02-21 20:13:04 +00:00
Anton Schwaighofer a055dfae9f
ENH: Add code to create montages from WSI (#787) 2023-02-09 19:50:07 +00:00
Harshita Sharma ebc030e5f2
ENH: Stratify PR and ROC curves by metadata (#788)
In this PR:
- `stratify_plots_by` parameter is introduced in BaseMIL to specify
metadata column on which the output PR and ROC curves can be stratified
- Functionality is added to plot the output curves stratified by
metadata
- Corresponding tests are added

---------

Co-authored-by: Harshita Sharma <t-hsharma@microsoft.com>
2023-02-08 12:33:43 +00:00
Harshita Sharma ad72411cf4
ENH: Add ROC curve to plot options (#780)
ROC curve is added as a plot option. Tests are updated for ROC and PR
curves

---------

Co-authored-by: Harshita Sharma <t-hsharma@microsoft.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-02-03 13:20:01 +00:00
Kenza Bouzid 7d96412236
ENH: Add extra slides to attention heatmaps plots (#778)
Add option to include an extra slide to the the attention heatmap plots.
2023-02-01 15:46:18 +00:00
Kenza Bouzid ca4eb45670
BUG: Gather results causes OOM for very large bag_size (#765)
We discovered a bug after merging #754 val_set_is_dist was used as a
flag to gather_results. It was defined as
 val_set_is_dist  = pl_replace_sampler_ssp and max_num_gpus > 1 
However max_num_gpus is set to -1 by default. So val_set_is_dist was
always False.
Now that we deprecated this flag results got gathered. This blows up the
memory when we use very large bag_size (1200).
Therefore we only gather if save_intermediate_outputs is True or if it's
an extra validation epoch.
A test is added to make sure gather_results is called when expected only
2023-01-25 09:00:29 +00:00
Kenza Bouzid 5d6468d507
ENH: Deprecate val_set_is_dist (#754)
-No need to check if validation set is distributed now that we can shard
evaluation (test and val) dataloaders without duplications #743 (it will
be distributed anyways)
-Tests tiles_selction, outputs_gathering and loss_callback are updated
to account for uneven samples scenario
2023-01-24 09:13:11 +00:00
Kenza Bouzid 565e7b1e7f
ENH: Use UnrepeatedDistributedSampler for validation and test (#743)
Use UnrepeatedDistributedSampler to avoid duplicating samples when
pl_replace_sampler_ddp is set to false
2023-01-20 13:22:49 +00:00
Harshita Sharma 196d0559c1
BUG: Subsample tiles without replacement (#732)
Current transform `SubSampled` to sample and shuffle the tiles does so
with replacement. In this PR, we ensure that tiles are sampled without
replacement.

Co-authored-by: Harshita Sharma <t-hsharma@microsoft.com>
2023-01-16 14:33:32 +00:00
Anton Schwaighofer a9d48b5182
ENH: Re-enable a test for SSL encoders (#726)
Re-enable tests that had been disabled in #487. For that, remove the
code duplication we had in getting an AML workspace specifically for
unit tests. `get_workspace` now can read settings from environment
variables.
2023-01-12 09:52:00 +00:00
Kenza Bouzid a5a18a8a92
ENH: Improve Attention Heatmaps plots (#723)
- Add attention histogram plot option
- Add original slide without overlay to heatmaps plots 
- Change colormap from Reds to Spectral_r
- Remove rectangle borders for smoother heatmaps
2023-01-10 11:25:07 +00:00
Anton Schwaighofer cdbac68fc4
ENH: Allow low-priority preemption after training (#722)
Jobs that get interrupted after training and then re-start will not find
an inference checkpoint and fail. This PR adds logic to search for that
checkpoint in AzureML.
2023-01-09 15:15:38 +00:00
Anton Schwaighofer 7373efc1ab
ENH: Reduce logging noise in test suite (#718)
Output of the test suite is cluttered and difficult to navigate in the
browser. Reduce output from dependent packages.
2023-01-06 13:24:31 +00:00
Kenza Bouzid 54cf5b5157
BUG: Fix slow-path warning in tests that use MockPandaSlidesGenerator (#717)
Closes #716 
Test with OpenSlide backend as well now that the tiffiles are not
corrupted anymore -> properly compressed and saved in chunks by
specifying tile_size in tiffwriter options
2023-01-03 14:58:49 +00:00
Kenza Bouzid 591a16b144
ENH: Add diagnostics tools (#695)
Add TimerWrapper transform and elapsed_timer + refactor load to print
warnings about failure slides

Co-authored-by: Anton Schwaighofer <antonsc@microsoft.com>
2022-12-21 08:49:09 +00:00
Anton Schwaighofer 7d9d94b92d
ENH: Improve PR workflows (#697)
* Run `pytest` and `pytest` on GPUs in parallel rather than sequentially.
* Cancel existing runs from previous pushes
* Fix dependency problem in hi-ml PR
* Reduce logging noise from `numba`
2022-12-19 14:56:08 +00:00
Kenza Bouzid c98b27a0d7
ENH: Extract coordinates from tensors metada (#677)
- Add coordinates to slides pipeline
- Refactor DeepMILModule into a single class

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-24 15:21:27 +00:00
Kenza Bouzid 615c8ad188
ENH: Enable LoadROId with Openslide (#672)
Refactor LoadRoiD/LoadPandaRoid transforms to work with OpenSlide and
removed params redundancy with LoadingParams class.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-22 22:51:34 +00:00
Kenza Bouzid e68f9b1db7
ENH: Upgrade monai to 1.0.1 (#668)
Upgrade monai to 1.0.1 
Note that we now need to convert monai outputs to torch tensors since
Rand/GridPatchd transforms return MetaTensors a new data structure in
the latest releases. This is handled in the collate function
2022-11-18 14:20:26 +00:00
Kenza Bouzid a1f580576c
ENH: Parameterize CuCim backend (#661)
Add wsi_reader_args to be able to use different backend
2022-11-15 13:28:59 +00:00
Kenza Bouzid b8a1ae0bc0 ENH: Small Fixes for Transfer Main merge 2022-11-14 11:24:17 +00:00
Kenza Bouzid 1034324c51
ENH: Add pl_replace_sampler_ddp flag for small validation sets (#648)
- Add pl_replace_sampler_ddp to be able to avoid validation data
distribution -> make sure all processes validate on the entire
validation set (reduce will give the same mean)
- Log extra validation outputs with a different prefix
- Refactor ClassifierParams 
- Add specific batch size for inference

Random [broken pipe
error](https://ml.azure.com/experiments/id/c4ad55a7-ce24-46a5-be8e-0fb478edf47e/runs/refs_pull_648_merge_1667920946_f585577d?wsid=/subscriptions/a85ceddd-892e-4637-ae4b-67d15ddf5f2b/resourceGroups/health-ml/providers/Microsoft.MachineLearningServices/workspaces/hi-ml&tid=72f988bf-86f1-41af-91ab-2d7cd011db47#outputsAndLogs)
2022-11-11 13:12:07 +00:00
Kenza Bouzid e30a0d1f6d
ENH: Merge Main into Transfer Main (#653)
Sync 32 commits from main

Co-authored-by: Fernando Pérez-García <fepegar@gmail.com>
Co-authored-by: Shruthi42 <13177030+Shruthi42@users.noreply.github.com>
Co-authored-by: vale-salvatelli <vale-salvatelli@users.noreply.github.com>
Co-authored-by: Melissa Bristow <66642528+mebristo@users.noreply.github.com>
Co-authored-by: Anton Schwaighofer <antonsc@microsoft.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fernando Pérez-García <fperezgarcia@microsoft.com>
Co-authored-by: Ozan Oktay <ozan.oktay@microsoft.com>
2022-11-10 18:36:40 +00:00
Harshita Sharma 6ba3cfe685
BUG: Fix HTML report (#647)
In this PR:
- Fix is introduced to handle missing cross-validation rounds (e.g., when a round fails)
- Extra validation epoch is handled
- Downloading the AML metrics json and saving it as a dataframe is separated into two functions (current version gives a `KeyError` when the json is downloaded for the first time)

Co-authored-by: Harshita Sharma <t-hsharma@microsoft.com>
2022-11-07 09:39:09 +00:00
Kenza Bouzid 41d30807aa
ENH: Download Checkpoints across AML workspaces (#642)
Enable checkpoints transfer across AML workspaces

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Anton Schwaighofer <antonsc@microsoft.com>
2022-11-01 17:38:37 +00:00
Kenza Bouzid 431ff2769c
ENH: Extend StainNormalisation Transform to work with Slides Pipeline (#644)
Adjust the input/output shapes.
2022-10-28 10:57:02 +01:00
Kenza Bouzid b2e873daa5
ENH: Separate attention heatmap and slide thumbnail plot options (#640)
Dissociate thumbnails and heatmaps plots to flexibly remove/add each of
these plot options.
Motivations: thumbnail plots can be costly, so we might want to omit it
sometime while including heatmap plots and vice versa.
2022-10-24 09:15:38 +01:00
Kenza Bouzid 2f39328a56
ENH: Enable heatmaps and thumbnails plots for WSI without masks (#637)
Use LoadROId for WSI without masks.
2022-10-19 16:35:52 +01:00
Kenza Bouzid e2c1ca1cb4
ENH: Track validation loss and add entropy value (#629)
Add entropy values to detect ambiguity and track validation loss during training
2022-10-12 13:24:25 +00:00
Kenza Bouzid fce049b4a2
ENH: Add Loss Outliers Analysis callback (#618)
Add LossAnalysisCallback to plot loss heatmaps + scatter plots and save
loss ranks and their statistics.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-05 13:00:39 +01:00
Kenza Bouzid d385f331a9
ENH: Refactor extra validation epoch logic (#608)
Avoid accessing sensitive attributes from the runner
Add on_extra_val_epoch_start hook to avoid confusion
2022-09-23 09:26:34 +01:00
Kenza Bouzid ad59214ed1
ENH: Make crossval html report generic to all hyperdrive runs (#605)
* Add commandline arguments to parametrise child runs arg identifier and primary metric to get best_epoch.
* Rename all crossval functions to hyperdrive ones to make it generic
2022-09-16 09:09:42 +01:00
Kenza Bouzid 71066ed7df
BUG: Fix top bottom tiles selection mismatch. (#599)
For small validation sets and poor performance models, we sometimes end up with some slides falsely belonging to TP/FN cases.
We need to make sure thay top_heaps contain only true cases and bottom ones, only false cases.
Check predicted vs true label before pushing into slides_heaps to make sure we only push true predictions in top_slides_heaps and false ones in bottom_slides_heaps
2022-09-13 21:24:28 +01:00
Harshita Sharma f7c21a622a
ENH: Dropout in transformer layers in DeepMIL (#590)
In this PR:
- transformer_dropout parameter is added to TransformerPooling and TransformerPoolingBenchmark pooling layers.
- Tests are updated with the transformer_dropout parameter.
2022-09-05 11:20:24 +01:00
vale-salvatelli 98c924a6d7
ENH: Adding PR curve plot for val and test for single fold (#585) 2022-08-30 09:54:29 +01:00
Kenza Bouzid a3d4fc6148
ENH: Log epoch of best checkpoint (#584)
Add a log to print the epoch of best checkpoint.
2022-08-25 12:27:42 +01:00
Melissa Bristow 802be95232 fix best checkpoint name 2022-08-24 17:48:09 +01:00
Kenza Bouzid b8720bfdd3
BUG: Fix probability scores displayed on histo plots (#581)
We used to display probabilities of ground truth labels instead of predicted ones.
2022-08-22 13:17:10 +01:00