Valentin Boussot commited on
Commit
7659e57
·
1 Parent(s): 234b9b4

Add finetune models

Browse files
Finetune/CV_1.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:150085badb5b46d7c5031ce3a4f3e349e7a9b9af82c0737e0a09851de7b3d606
3
+ size 208936686
Finetune/Config.yml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Trainer:
2
+ Model:
3
+ classpath: Model:UNetpp
4
+ UNetpp:
5
+ outputs_criterions:
6
+ Head:Tanh:
7
+ targets_criterions:
8
+ CT:
9
+ criterions_loader:
10
+ MAE:
11
+ schedulers:
12
+ Constant:
13
+ nb_step: 0
14
+ value: 1
15
+ is_loss: true
16
+ group: 0
17
+ start: 0
18
+ stop: None
19
+ accumulation: false
20
+ reduction: mean
21
+ IMPACTReg/1:
22
+ name: SAM
23
+ model_name: SAM2.1/SAM2.1_Small.pt
24
+ shape:
25
+ - 0
26
+ - 0
27
+ in_channels: 3
28
+ loss: torch:nn:L1Loss
29
+ weights:
30
+ - 0
31
+ - 1
32
+ - 1
33
+ size_average: None
34
+ reduce: None
35
+ reduction: mean
36
+ schedulers:
37
+ Constant:
38
+ nb_step: 0
39
+ value: 0.5
40
+ is_loss: true
41
+ group: 0
42
+ start: 0
43
+ stop: None
44
+ accumulation: false
45
+ CT;MASK:
46
+ criterions_loader:
47
+ MAE:
48
+ schedulers:
49
+ Constant:
50
+ nb_step: 0
51
+ value: 1
52
+ is_loss: false
53
+ group: 0
54
+ start: 0
55
+ stop: None
56
+ accumulation: false
57
+ reduction: mean
58
+ schedulers:
59
+ PolyLRScheduler:
60
+ initial_lr: 0.01
61
+ max_steps: 500
62
+ exponent: 0.9
63
+ current_step: 0
64
+ nb_step: 0
65
+ Patch: None
66
+ optimizer:
67
+ name: SGD
68
+ lr: 0.01
69
+ momentum: 0.99
70
+ dampening: 0
71
+ weight_decay: 3e-05
72
+ nesterov: true
73
+ maximize: false
74
+ foreach: None
75
+ differentiable: false
76
+ fused: None
77
+ nb_channel: 5
78
+ Dataset:
79
+ groups_src:
80
+ MASK:
81
+ groups_dest:
82
+ MASK:
83
+ transforms: None
84
+ patch_transforms: None
85
+ is_input: false
86
+ CT:
87
+ groups_dest:
88
+ CT:
89
+ transforms:
90
+ Clip:
91
+ min_value: -1024
92
+ max_value: 3071
93
+ save_clip_min: true
94
+ save_clip_max: true
95
+ mask: None
96
+ Statistics: {}
97
+ Normalize:
98
+ lazy: true
99
+ channels: None
100
+ min_value: -1
101
+ max_value: 1
102
+ inverse: false
103
+ patch_transforms:
104
+ Normalize:
105
+ lazy: false
106
+ channels: None
107
+ min_value: -1
108
+ max_value: 1
109
+ inverse: false
110
+ is_input: false
111
+ CBCT_IMPACT:
112
+ groups_dest:
113
+ CBCT:
114
+ transforms:
115
+ Clip:
116
+ min_value: min
117
+ max_value: percentile:99.5
118
+ save_clip_min: false
119
+ save_clip_max: false
120
+ mask: None
121
+ Statistics: {}
122
+ Normalize:
123
+ lazy: true
124
+ channels: None
125
+ min_value: -1
126
+ max_value: 1
127
+ inverse: false
128
+ patch_transforms:
129
+ Normalize:
130
+ lazy: false
131
+ channels: None
132
+ min_value: -1
133
+ max_value: 1
134
+ inverse: false
135
+ is_input: true
136
+ augmentations:
137
+ DataAugmentation_0:
138
+ data_augmentations:
139
+ Flip:
140
+ f_prob:
141
+ - 0
142
+ - 0.5
143
+ - 0.5
144
+ prob: 1
145
+ nb: 1
146
+ Patch:
147
+ patch_size:
148
+ - 1
149
+ - 320
150
+ - 320
151
+ overlap: None
152
+ mask: None
153
+ pad_value: -1
154
+ extend_slice: 4
155
+ subset: None
156
+ shuffle: true
157
+ filter: None
158
+ dataset_filenames:
159
+ - ./Dataset/:a:mha
160
+ inline_augmentations: true
161
+ use_cache: true
162
+ batch_size: 32
163
+ validation: None
164
+ train_name: FT_0
165
+ manual_seed: 32
166
+ epochs: 100
167
+ it_validation: 2500
168
+ autocast: false
169
+ gradient_checkpoints: None
170
+ gpu_checkpoints: None
171
+ ema_decay: 0
172
+ data_log:
173
+ - CT/IMAGES/5
174
+ - CBCT/IMAGES/5
175
+ - Head:Tanh/IMAGES/5
176
+ save_checkpoint_mode: ALL
177
+ EarlyStopping:
178
+ monitor: []
179
+ patience: 30
180
+ min_delta: 0.0
181
+ mode: min
Finetune/Evaluation.yml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Evaluator:
2
+ metrics:
3
+ Output:
4
+ targets_criterions:
5
+ Reference;Mask:
6
+ criterions_loader:
7
+ MAESaveMap:
8
+ reduction: mean
9
+ dataset: ./Evaluations/ImpactSynth/Output:mha
10
+ group: MAE_map
11
+ PSNR:
12
+ dynamic_range: None
13
+ SSIM:
14
+ dynamic_range: None
15
+ SAM_Perceptual: {}
16
+ IMPACTReg:
17
+ name: Reg
18
+ model_name: TS/M291.pt
19
+ shape:
20
+ - 0
21
+ - 0
22
+ - 0
23
+ in_channels: 1
24
+ loss: torch:nn:MSELoss
25
+ weights:
26
+ - 0
27
+ - 1
28
+ size_average: None
29
+ reduce: None
30
+ reduction: mean
31
+ Output_seg:
32
+ targets_criterions:
33
+ Reference_seg;Mask:
34
+ criterions_loader:
35
+ DiceSaveMap:
36
+ labels: None
37
+ dataset: ./Evaluations/ImpactSynth/Output:mha
38
+ group: Seg_MAE_map
39
+ Dataset:
40
+ groups_src:
41
+ Mask_0:
42
+ groups_dest:
43
+ Mask:
44
+ transforms:
45
+ TensorCast:
46
+ dtype: uint8
47
+ Volume_0:
48
+ groups_dest:
49
+ Output:
50
+ transforms:
51
+ Statistics: {}
52
+ TensorCast:
53
+ dtype: float32
54
+ patch_transforms: None
55
+ is_input: false
56
+ Output_seg:
57
+ transforms:
58
+ KonfAIInference:
59
+ repo_id: VBoussot/TotalSegmentator-KonfAI
60
+ model_name: total-3mm
61
+ checkpoints_name:
62
+ - M297.pt
63
+ number_of_tta: 0
64
+ number_of_mc: 0
65
+ per_channel: false
66
+ Save:
67
+ dataset: ./Evaluations/ImpactSynth/Output:mha
68
+ group: None
69
+ Reference_0:
70
+ groups_dest:
71
+ Reference:
72
+ transforms:
73
+ Statistics: {}
74
+ TensorCast:
75
+ dtype: float32
76
+ patch_transforms: None
77
+ is_input: false
78
+ Reference_seg:
79
+ transforms:
80
+ KonfAIInference:
81
+ repo_id: VBoussot/TotalSegmentator-KonfAI
82
+ model_name: total-3mm
83
+ checkpoints_name:
84
+ - M297.pt
85
+ number_of_tta: 0
86
+ number_of_mc: 0
87
+ per_channel: false
88
+ Save:
89
+ dataset: ./Evaluations/ImpactSynth/Output:mha
90
+ group: None
91
+ subset: None
92
+ dataset_filenames:
93
+ - ./Dataset:a:mha
94
+ validation: None
95
+ train_name: ImpactSynth
Finetune/Model.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from konfai.network import network
2
+ import segmentation_models_pytorch as smp
3
+ import torch
4
+
5
+ class Head(network.ModuleArgsDict):
6
+
7
+ def __init__(self):
8
+ super().__init__()
9
+ self.add_module("Tanh", torch.nn.Tanh())
10
+
11
+ class UNetpp(network.Network):
12
+
13
+ def __init__(self,
14
+ optimizer : network.OptimizerLoader = network.OptimizerLoader(),
15
+ schedulers: dict[str, network.LRSchedulersLoader] = {
16
+ "default:ReduceLROnPlateau": network.LRSchedulersLoader(0)
17
+ },
18
+ outputs_criterions: dict[str, network.TargetCriterionsLoader] = {"default" : network.TargetCriterionsLoader()},
19
+ nb_channel : int = 5):
20
+ super().__init__(in_channels = nb_channel, optimizer = optimizer, schedulers = schedulers, outputs_criterions = outputs_criterions, dim = 2)
21
+ self.add_module("model", smp.UnetPlusPlus(
22
+ encoder_name="resnet34",
23
+ encoder_weights=None,
24
+ in_channels=nb_channel,
25
+ classes=1,
26
+ activation=None
27
+ ))
28
+ self.add_module("Head", Head())
Finetune/Prediction.yml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Predictor:
2
+ Model:
3
+ classpath: Model:UNetpp
4
+ UNetpp:
5
+ outputs_criterions: None
6
+ nb_channel: 5
7
+ Dataset:
8
+ groups_src:
9
+ Volume_0:
10
+ groups_dest:
11
+ MASK:
12
+ transforms:
13
+ KonfAIInference:
14
+ repo_id: VBoussot/TotalSegmentator-KonfAI
15
+ model_name: body
16
+ checkpoints_name:
17
+ - M598.pt
18
+ number_of_tta: 0
19
+ number_of_mc_dropout: 0
20
+ per_channel: false
21
+ Save:
22
+ dataset: ./Dataset:mha
23
+ patch_transforms: None
24
+ is_input: false
25
+ Volume:
26
+ transforms:
27
+ Clip/0:
28
+ min_value: -1024
29
+ max_value: 5000
30
+ save_clip_min: false
31
+ save_clip_max: false
32
+ mask: None
33
+ TensorCast:
34
+ dtype: int16
35
+ inverse: false
36
+ ResampleToResolution:
37
+ spacing:
38
+ - 1
39
+ - 1
40
+ - 3
41
+ inverse: true
42
+ Clip/1:
43
+ min_value: min
44
+ max_value: percentile:99.5
45
+ save_clip_min: false
46
+ save_clip_max: false
47
+ mask: None
48
+ Normalize:
49
+ lazy: false
50
+ channels: None
51
+ min_value: -1
52
+ max_value: 1
53
+ inverse: false
54
+ patch_transforms: None
55
+ is_input: true
56
+ augmentations:
57
+ DataAugmentation_0:
58
+ data_augmentations:
59
+ Flip:
60
+ f_prob:
61
+ - 0
62
+ - 0.5
63
+ - 0.5
64
+ prob: 1
65
+ nb: 2
66
+ Patch:
67
+ patch_size:
68
+ - 1
69
+ - 512
70
+ - 512
71
+ overlap: None
72
+ mask: None
73
+ pad_value: -1
74
+ extend_slice: 4
75
+ subset: None
76
+ filter: None
77
+ dataset_filenames:
78
+ - ./Dataset:mha
79
+ use_cache: false
80
+ batch_size: 8
81
+ outputs_dataset:
82
+ Head:Tanh:
83
+ OutputDataset:
84
+ name_class: OutSameAsGroupDataset
85
+ before_reduction_transforms:
86
+ UnNormalize:
87
+ min_value: -1024
88
+ max_value: 3071
89
+ TensorCast:
90
+ dtype: int16
91
+ inverse: false
92
+ Mask:
93
+ path: MASK
94
+ value_outside: -1024
95
+ after_reduction_transforms:
96
+ InferenceStack:
97
+ dataset: Predictions/ImpactSynth/Output:mha
98
+ name: InferenceStack
99
+ mode: mean
100
+ final_transforms: None
101
+ dataset_filename: Output:mha
102
+ inverse_transform: true
103
+ group: sCT
104
+ same_as_group: Volume_0:Volume
105
+ patch_combine: None
106
+ reduction: Concat
107
+ Concat: {}
108
+ train_name: ImpactSynth
109
+ manual_seed: 32
110
+ gpu_checkpoints: None
111
+ images_log: None
112
+ combine: Concat
113
+ autocast: false
114
+ data_log: None
115
+ Concat: {}
Finetune/Uncertainty.yml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Evaluator:
2
+ metrics:
3
+ Uncertainty:
4
+ targets_criterions:
5
+ None:
6
+ criterions_loader:
7
+ Mean:
8
+ name: Uncertainty
9
+ Comformity:
10
+ targets_criterions:
11
+ None:
12
+ criterions_loader:
13
+ Mean:
14
+ name: Comformity
15
+ Dataset:
16
+ groups_src:
17
+ Volume_0:
18
+ groups_dest:
19
+ Uncertainty:
20
+ transforms:
21
+ Variance: {}
22
+ Percentage:
23
+ baseline: 784.24
24
+ Save:
25
+ dataset: ./Uncertainties/ImpactSynth/Output:mha
26
+ group: None
27
+ Comformity:
28
+ transforms:
29
+ KonfAIInference:
30
+ repo_id: VBoussot/TotalSegmentator-KonfAI
31
+ model_name: total-3mm
32
+ checkpoints_name:
33
+ - M297.pt
34
+ number_of_tta: 0
35
+ number_of_mc: 0
36
+ per_channel: true
37
+ Save/1:
38
+ dataset: ./Uncertainties/ImpactSynth/Output:mha
39
+ group: None
40
+ SegmentationDisagreement: {}
41
+ Save/2:
42
+ dataset: ./Uncertainties/ImpactSynth/Output:mha
43
+ group: Comformity_var
44
+ subset: None
45
+ dataset_filenames:
46
+ - ./Dataset:mha
47
+ validation: None
48
+ train_name: ImpactSynth
Finetune/app.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "display_name": "Synthesis: CBCT",
3
+ "short_description": "Supervised whole-body CBCT-to-sCT model for SynthRAD Task 2.<br><br><b>Training data:</b><br>929 paired CT-CBCT cases from SynthRAD 2023+2025.<br><br><b>How to cite:</b><br><cite>V. Boussot et al., <i>Why Registration Quality Matters: Enhancing sCT Synthesis with IMPACT-Based Registration</i>, arXiv preprint arXiv:2510.21358, <a href=\"https://doi.org/10.48550/arXiv.2510.21358\">https://doi.org/10.48550/arXiv.2510.21358</a>.</cite>",
4
+ "description": "<b>Description:</b><br>Supervised whole-body CBCT-to-sCT model trained using SynthRAD 2023 and SynthRAD 2025 Task 2 datasets, distributed as five validation-fold checkpoints (<code>CV_0.pt</code> to <code>CV_4.pt</code>). Training pairs are aligned with IMPACTReg. The available Task 2 data include 291 patients from SynthRAD 2023 and 638 patients from SynthRAD 2025, for 929 patients in total.<br><br><b>Architecture and loss:</b><br>2.5D UNet++ with a ResNet34 encoder, trained with KonfAI and optimized using IMPACT-Synth, a perceptual loss leveraging semantic priors from <b>SAM 2.1-s</b>.<br><br><b>Training data:</b><br>Whole-body paired CT-CBCT volumes come from SynthRAD 2023 Task 2 (<code>brain</code>, <code>pelvis</code>) and SynthRAD 2025 Task 2 (<code>AB</code>, <code>HN</code>, <code>TH</code>). Additional OOD evaluation cohorts are available for <code>AB_ood</code>, <code>HN_ood</code>, and <code>TH_ood</code>. Pairs are aligned with IMPACTReg, and the associated transform files are available at <a href=\"https://huggingface.co/datasets/VBoussot/synthrad2023-impact-registration\">synthrad2023-impact-registration</a> and <a href=\"https://huggingface.co/datasets/VBoussot/synthrad2025-impact-registration\">synthrad2025-impact-registration</a>. The files <code>CrossValidation_0.txt</code> to <code>CrossValidation_4.txt</code> correspond to validation folds for the distributed checkpoints, and <code>Validation.txt</code> contains 150 release-validation patients.<br><br><b>Release performance (CV overall, n=150):</b><br>Dice 0.758, MAE 53.55 HU, SSIM 0.939, PSNR 32.09 dB, SAM 13.70, Reg 1.04, Uncertainty 784.24.<br><br><b>Inference note:</b><br>The prediction pipeline supports test-time augmentation and writes an averaged <code>InferenceStack</code> output that can also be used for uncertainty estimation.<br><br><b>How to cite:</b><br><cite>V. Boussot et al., <i>Why Registration Quality Matters: Enhancing sCT Synthesis with IMPACT-Based Registration</i>, arXiv preprint arXiv:2510.21358, <a href=\"https://doi.org/10.48550/arXiv.2510.21358\">https://doi.org/10.48550/arXiv.2510.21358</a>.</cite>",
5
+ "tta": 2,
6
+ "mc_dropout": false,
7
+ "models": ["CV_0.pt", "CV_1.pt", "CV_2.pt", "CV_3.pt", "CV_4.pt"],
8
+ "inputs": {
9
+ "CBCT": {
10
+ "display_name": "CBCT",
11
+ "volume_type": "VOLUME",
12
+ "required": true
13
+ }
14
+ },
15
+
16
+ "outputs": {
17
+ "sCT": {
18
+ "display_name": "sCT",
19
+ "volume_type": "VOLUME",
20
+ "required": true
21
+ }
22
+ },
23
+
24
+ "inputs_evaluations": {
25
+ "Image": {
26
+ "Evaluation.yml": {
27
+ "sCT": {
28
+ "display_name": "sCT",
29
+ "volume_type": "VOLUME",
30
+ "required": true
31
+ },
32
+ "CT": {
33
+ "display_name": "CT",
34
+ "volume_type": "VOLUME",
35
+ "required": true
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
Finetune/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ segmentation_models_pytorch