Skip to content

Commit

Permalink
Bugfix/limit taskhead names (#415)
Browse files Browse the repository at this point in the history
* rename target->seg

* limit task head names

* task head name target->seg

---------

Co-authored-by: Benjamin Morris <[email protected]>
  • Loading branch information
benjijamorris and Benjamin Morris authored Aug 14, 2024
1 parent 26b77af commit 965b371
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
18 changes: 9 additions & 9 deletions configs/data/im2im/segmentation_plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ transforms:
- ${target_col1}
- ${target_col2}
base_image_key: ${base_image_col}
output_name: target
output_name: seg

- _target_: monai.transforms.ToTensord
keys:
- ${source_col}
- target
- seg
- ${exclude_mask_col}
dtype: float16

#crop
- _target_: cyto_dl.image.transforms.RandomMultiScaleCropd
keys:
- ${source_col}
- target
- seg
- ${exclude_mask_col}
patch_shape: ${data._aux.patch_shape}
patch_per_image: ${data._aux.patch_per_image}
Expand Down Expand Up @@ -143,12 +143,12 @@ transforms:
- ${target_col1}
- ${target_col2}
base_image_key: ${base_image_col}
output_name: target
output_name: seg

- _target_: monai.transforms.ToTensord
keys:
- ${source_col}
- target
- seg
- ${exclude_mask_col}
dtype: float16

Expand Down Expand Up @@ -232,20 +232,20 @@ transforms:
- ${target_col1}
- ${target_col2}
base_image_key: ${base_image_col}
output_name: target
output_name: seg

- _target_: monai.transforms.ToTensord
keys:
- ${source_col}
- target
- seg
- ${exclude_mask_col}
dtype: float16

# #crop
- _target_: cyto_dl.image.transforms.RandomMultiScaleCropd
keys:
- ${source_col}
- target
- seg
- ${exclude_mask_col}
patch_shape: ${data._aux.patch_shape}
patch_per_image: ${data._aux.patch_per_image}
Expand All @@ -254,7 +254,7 @@ transforms:
_aux:
patch_per_image: 1
_scales_dict:
- - target
- - seg
- [1]
- - ${source_col}
- [1]
Expand Down
2 changes: 1 addition & 1 deletion configs/model/im2im/segmentation_plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ backbone:
filters: ${model._aux.filters}

task_heads:
target:
seg:
_target_: cyto_dl.nn.head.MaskHead
mask_key: ${exclude_mask_col}
loss:
Expand Down
6 changes: 6 additions & 0 deletions cyto_dl/models/im2im/multi_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def __init__(
}

for head in task_heads.keys():
assert head not in (
"loss",
"pred",
"target",
"input",
), "Task head name cannot be 'loss', 'pred', 'target', or 'input'"
_DEFAULT_METRICS.update(
{
f"train/loss/{head}": MeanMetric(),
Expand Down

0 comments on commit 965b371

Please sign in to comment.