Add ImpactSeg body
Browse files- body/Body.pt +3 -0
- body/Evaluation.yml +29 -0
- body/Model.py +53 -0
- body/Prediction.yml +78 -0
- body/app.json +51 -0
- body/requirements.txt +1 -0
body/Body.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0a4652d0c8139e2d3ce86247bf3e050671de369fe982a701bf6bf76304131c7a
|
| 3 |
+
size 423981609
|
body/Evaluation.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Evaluator:
|
| 2 |
+
metrics:
|
| 3 |
+
Output:
|
| 4 |
+
targets_criterions:
|
| 5 |
+
Reference;Mask:
|
| 6 |
+
criterions_loader:
|
| 7 |
+
DiceSaveMap:
|
| 8 |
+
labels: None
|
| 9 |
+
dataset: ./Evaluations/ImpactSeg-Body/Output:mha
|
| 10 |
+
group: Seg_MAE_map
|
| 11 |
+
Dataset:
|
| 12 |
+
groups_src:
|
| 13 |
+
Mask_0:
|
| 14 |
+
groups_dest:
|
| 15 |
+
Mask:
|
| 16 |
+
transforms: None
|
| 17 |
+
Volume_0:
|
| 18 |
+
groups_dest:
|
| 19 |
+
Output:
|
| 20 |
+
transforms: None
|
| 21 |
+
Reference_0:
|
| 22 |
+
groups_dest:
|
| 23 |
+
Reference:
|
| 24 |
+
transforms: None
|
| 25 |
+
subset: None
|
| 26 |
+
dataset_filenames:
|
| 27 |
+
- ./Dataset:a:mha
|
| 28 |
+
validation: None
|
| 29 |
+
train_name: ImpactSeg-Body
|
body/Model.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from torch import nn
|
| 3 |
+
|
| 4 |
+
from dynamic_network_architectures.architectures.unet import ResidualEncoderUNet
|
| 5 |
+
from konfai.network import network
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def _replace_unpicklable_identities(module: nn.Module) -> None:
|
| 9 |
+
"""Replace library lambdas such as ``lambda x: x`` with ``nn.Identity``."""
|
| 10 |
+
for child in module.modules():
|
| 11 |
+
if hasattr(child, "skip") and callable(child.skip) and not isinstance(child.skip, nn.Module):
|
| 12 |
+
child.skip = nn.Identity()
|
| 13 |
+
if hasattr(child, "nonlin2") and callable(child.nonlin2) and not isinstance(child.nonlin2, nn.Module):
|
| 14 |
+
child.nonlin2 = nn.Identity()
|
| 15 |
+
|
| 16 |
+
class ResEncMCT(network.Network):
|
| 17 |
+
def __init__(
|
| 18 |
+
self,
|
| 19 |
+
optimizer: network.OptimizerLoader = network.OptimizerLoader(),
|
| 20 |
+
schedulers: dict[str, network.LRSchedulersLoader] = {
|
| 21 |
+
"default:ReduceLROnPlateau": network.LRSchedulersLoader(0)
|
| 22 |
+
},
|
| 23 |
+
outputs_criterions: dict[str, network.TargetCriterionsLoader] = {"default": network.TargetCriterionsLoader()},
|
| 24 |
+
in_channels: int = 5,
|
| 25 |
+
nb_class: int = 132,
|
| 26 |
+
) -> None:
|
| 27 |
+
super().__init__(
|
| 28 |
+
in_channels=in_channels,
|
| 29 |
+
optimizer=optimizer,
|
| 30 |
+
schedulers=schedulers,
|
| 31 |
+
outputs_criterions=outputs_criterions,
|
| 32 |
+
dim=2,
|
| 33 |
+
)
|
| 34 |
+
self.add_module("DecoderOutputs", ResidualEncoderUNet(
|
| 35 |
+
input_channels=in_channels,
|
| 36 |
+
n_stages=7,
|
| 37 |
+
features_per_stage=(32, 64, 128, 256, 512, 512, 512),
|
| 38 |
+
conv_op=nn.Conv2d,
|
| 39 |
+
kernel_sizes=3,
|
| 40 |
+
strides=(1, 2, 2, 2, 2, 2, 2),
|
| 41 |
+
n_blocks_per_stage=(1, 3, 4, 6, 6, 6, 6),
|
| 42 |
+
num_classes=nb_class,
|
| 43 |
+
n_conv_per_stage_decoder=(1, 1, 1, 1, 1, 1),
|
| 44 |
+
conv_bias=True,
|
| 45 |
+
norm_op=nn.InstanceNorm2d,
|
| 46 |
+
norm_op_kwargs={"eps": 1e-5, "affine": True},
|
| 47 |
+
dropout_op=None,
|
| 48 |
+
dropout_op_kwargs=None,
|
| 49 |
+
nonlin=nn.LeakyReLU,
|
| 50 |
+
nonlin_kwargs={"inplace": True},
|
| 51 |
+
deep_supervision=False,
|
| 52 |
+
))
|
| 53 |
+
_replace_unpicklable_identities(self.DecoderOutputs)
|
body/Prediction.yml
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Predictor:
|
| 2 |
+
Model:
|
| 3 |
+
classpath: Model:ResEncMCT
|
| 4 |
+
ResEncMCT:
|
| 5 |
+
in_channels: 5
|
| 6 |
+
nb_class: 12
|
| 7 |
+
outputs_criterions: None
|
| 8 |
+
Dataset:
|
| 9 |
+
groups_src:
|
| 10 |
+
Volume_0:
|
| 11 |
+
groups_dest:
|
| 12 |
+
Volume:
|
| 13 |
+
transforms:
|
| 14 |
+
TensorCast:
|
| 15 |
+
dtype: float32
|
| 16 |
+
inverse: false
|
| 17 |
+
ResampleToResolution:
|
| 18 |
+
spacing:
|
| 19 |
+
- 3
|
| 20 |
+
- 3
|
| 21 |
+
- 0
|
| 22 |
+
inverse: true
|
| 23 |
+
Standardize:
|
| 24 |
+
lazy: false
|
| 25 |
+
mean: None
|
| 26 |
+
std: None
|
| 27 |
+
mask: None
|
| 28 |
+
inverse: false
|
| 29 |
+
patch_transforms: None
|
| 30 |
+
is_input: true
|
| 31 |
+
augmentations: None
|
| 32 |
+
Patch:
|
| 33 |
+
patch_size:
|
| 34 |
+
- 1
|
| 35 |
+
- 192
|
| 36 |
+
- 192
|
| 37 |
+
overlap: None
|
| 38 |
+
mask: None
|
| 39 |
+
pad_value: -2
|
| 40 |
+
extend_slice: 4
|
| 41 |
+
subset: None
|
| 42 |
+
filter: None
|
| 43 |
+
dataset_filenames:
|
| 44 |
+
- ./Dataset/:mha
|
| 45 |
+
use_cache: false
|
| 46 |
+
batch_size: 32
|
| 47 |
+
num_workers: None
|
| 48 |
+
pin_memory: false
|
| 49 |
+
prefetch_factor: None
|
| 50 |
+
persistent_workers: None
|
| 51 |
+
outputs_dataset:
|
| 52 |
+
DecoderOutputs:
|
| 53 |
+
OutputDataset:
|
| 54 |
+
name_class: OutSameAsGroupDataset
|
| 55 |
+
before_reduction_transforms: None
|
| 56 |
+
after_reduction_transforms: None
|
| 57 |
+
final_transforms:
|
| 58 |
+
Softmax:
|
| 59 |
+
dim: 0
|
| 60 |
+
Argmax:
|
| 61 |
+
dim: 0
|
| 62 |
+
TensorCast:
|
| 63 |
+
dtype: uint8
|
| 64 |
+
inverse: true
|
| 65 |
+
dataset_filename: Output:mha
|
| 66 |
+
group: Output
|
| 67 |
+
same_as_group: Volume_0:Volume
|
| 68 |
+
patch_combine: None
|
| 69 |
+
inverse_transform: true
|
| 70 |
+
reduction: Mean
|
| 71 |
+
Mean: {}
|
| 72 |
+
train_name: ImpactSeg-Body
|
| 73 |
+
manual_seed: 42
|
| 74 |
+
gpu_checkpoints: None
|
| 75 |
+
images_log: None
|
| 76 |
+
combine: Mean
|
| 77 |
+
autocast: false
|
| 78 |
+
data_log: None
|
body/app.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"display_name": "Segmentation: IMPACTSeg CBCT/MR/CT",
|
| 3 |
+
"short_description": "<b>Description:</b><br><b>IMPACTSeg</b> is a multimodal anatomical segmentation model for <b>CBCT, MR, and CT</b> scans. It predicts <b>11 labels</b> spanning soft tissues, cavities, bones, and central structures, and was trained on <b>232 CBCT + 282 MR + 955 CT</b> cases.",
|
| 4 |
+
"description": "<b>Description:</b><br><b>IMPACTSeg</b> is a multimodal anatomical segmentation model packaged for inference with <b>KonfAI</b>. It is designed for <b>CBCT, MR, and CT</b> scans and produces a consistent set of <b>11 labels</b> across modalities.<br><br><b>Training cohort:</b><br><b>232 CBCT + 282 MR + 955 CT</b> cases.<br><br><b>Use case:</b><br>Automated multimodal segmentation for downstream analysis, quantitative workflows, and clinical research pipelines.",
|
| 5 |
+
"tta": 0,
|
| 6 |
+
"mc_dropout": 0,
|
| 7 |
+
"models": ["Body.pt"],
|
| 8 |
+
"inputs": {
|
| 9 |
+
"Volume": {
|
| 10 |
+
"display_name": "Input Volume",
|
| 11 |
+
"volume_type": "VOLUME",
|
| 12 |
+
"required": true
|
| 13 |
+
}
|
| 14 |
+
},
|
| 15 |
+
"outputs": {
|
| 16 |
+
"Segmentation": {
|
| 17 |
+
"display_name": "Segmentation",
|
| 18 |
+
"volume_type": "SEGMENTATION",
|
| 19 |
+
"required": true
|
| 20 |
+
}
|
| 21 |
+
},
|
| 22 |
+
"inputs_evaluations": {
|
| 23 |
+
"Image": {
|
| 24 |
+
"Evaluation.yml": {
|
| 25 |
+
"Segmentation": {
|
| 26 |
+
"display_name": "Output Segmentation",
|
| 27 |
+
"volume_type": "VOLUME",
|
| 28 |
+
"required": true
|
| 29 |
+
},
|
| 30 |
+
"GT_Segmentation": {
|
| 31 |
+
"display_name": "GT Segmentation",
|
| 32 |
+
"volume_type": "VOLUME",
|
| 33 |
+
"required": true
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
"terminology": {
|
| 39 |
+
"1": { "name": "subcutaneous_tissue", "color": "#F4A261" },
|
| 40 |
+
"2": { "name": "muscle", "color": "#E76F51" },
|
| 41 |
+
"3": { "name": "abdominal_cavity", "color": "#2A9D8F" },
|
| 42 |
+
"4": { "name": "thoracic_cavity", "color": "#264653" },
|
| 43 |
+
"5": { "name": "bones", "color": "#E9C46A" },
|
| 44 |
+
"6": { "name": "gland_structure", "color": "#8AB17D" },
|
| 45 |
+
"7": { "name": "pericardium", "color": "#C8553D" },
|
| 46 |
+
"8": { "name": "prosthetic_breast_implant", "color": "#B56576" },
|
| 47 |
+
"9": { "name": "mediastinum", "color": "#577590" },
|
| 48 |
+
"10": { "name": "spinal_cord", "color": "#6D597A" },
|
| 49 |
+
"11": { "name": "brain", "color": "#43AA8B" }
|
| 50 |
+
}
|
| 51 |
+
}
|
body/requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
dynamic_network_architectures
|