From 071dc527dd129f66c6c42752c06e87e46b9a8467 Mon Sep 17 00:00:00 2001 From: Matthias Hadlich Date: Wed, 8 Nov 2023 17:03:21 +0100 Subject: [PATCH] Add no scribbles model (#1586) * Add no_scribbles model to remove the scribbles Signed-off-by: Matthias Hadlich * Disable scribbles if flag is passed Signed-off-by: Matthias Hadlich * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Matthias Hadlich * Rework scribbles flag, now configurable via --conf Signed-off-by: Matthias Hadlich * Update README for scribbles flag and change to MONAILabel semantics Signed-off-by: Matthias Hadlich * Fix typos Signed-off-by: Matthias Hadlich --------- Signed-off-by: Matthias Hadlich Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- sample-apps/radiology/README.md | 3 ++- sample-apps/radiology/main.py | 43 ++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/sample-apps/radiology/README.md b/sample-apps/radiology/README.md index 83b3d53f7..49515ce96 100644 --- a/sample-apps/radiology/README.md +++ b/sample-apps/radiology/README.md @@ -188,7 +188,8 @@ the model to learn on new organ. | Name | Values | Description | |----------------------|--------------------|-----------------------------------------------------------------| | use_pretrained_model | **true**, false | Disable this NOT to load any pretrained weights | -| preload | true, **false** | Preload model into GPU | +| preload | true, **false** | Preload model into GPU | +| scribbles | **true**, false | Don't load the scribble models, useful for user studies | - Network: This model uses the [UNet](https://docs.monai.io/en/latest/networks.html#unet) as the default network. Researchers can define their own network or use one of the listed [here](https://docs.monai.io/en/latest/networks.html) - Labels diff --git a/sample-apps/radiology/main.py b/sample-apps/radiology/main.py index b51d07fbf..5d5ab348b 100644 --- a/sample-apps/radiology/main.py +++ b/sample-apps/radiology/main.py @@ -66,6 +66,8 @@ def __init__(self, app_dir, studies, conf): models = models.split(",") models = [m.strip() for m in models] + # Can be configured with --conf scribbles false or true + self.scribbles = conf.get("scribbles", "true") == "true" invalid = [m for m in models if m != "all" and not configs.get(m)] if invalid: print("") @@ -138,26 +140,27 @@ def init_infers(self) -> Dict[str, InferTask]: ################################################# # Scribbles ################################################# - infers.update( - { - "Histogram+GraphCut": HistogramBasedGraphCut( - intensity_range=(-300, 200, 0.0, 1.0, True), - pix_dim=(2.5, 2.5, 5.0), - lamda=1.0, - sigma=0.1, - num_bins=64, - labels=task_config.labels, - ), - "GMM+GraphCut": GMMBasedGraphCut( - intensity_range=(-300, 200, 0.0, 1.0, True), - pix_dim=(2.5, 2.5, 5.0), - lamda=5.0, - sigma=0.5, - num_mixtures=20, - labels=task_config.labels, - ), - } - ) + if self.scribbles: + infers.update( + { + "Histogram+GraphCut": HistogramBasedGraphCut( + intensity_range=(-300, 200, 0.0, 1.0, True), + pix_dim=(2.5, 2.5, 5.0), + lamda=1.0, + sigma=0.1, + num_bins=64, + labels=task_config.labels, + ), + "GMM+GraphCut": GMMBasedGraphCut( + intensity_range=(-300, 200, 0.0, 1.0, True), + pix_dim=(2.5, 2.5, 5.0), + lamda=5.0, + sigma=0.5, + num_mixtures=20, + labels=task_config.labels, + ), + } + ) ################################################# # Pipeline based on existing infers