FelixzeroSun commited on
Commit
19c1f58
·
verified ·
1 Parent(s): 775a95e

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +10 -0
  2. README.md +0 -3
  3. docker_task_1/.env +2 -0
  4. docker_task_1/260_gt_nnUNetResEncUNetLPlans.json +521 -0
  5. docker_task_1/262_gt_nnUNetResEncUNetLPlans.json +356 -0
  6. docker_task_1/264_gt_nnUNetResEncUNetLPlans.json +521 -0
  7. docker_task_1/Dockerfile +43 -0
  8. docker_task_1/__pycache__/base_algorithm.cpython-312.pyc +0 -0
  9. docker_task_1/__pycache__/revert_normalisation.cpython-312.pyc +0 -0
  10. docker_task_1/base_algorithm.py +205 -0
  11. docker_task_1/build.sh +4 -0
  12. docker_task_1/dynamic-network-architectures/.gitignore +113 -0
  13. docker_task_1/dynamic-network-architectures/LICENCE +201 -0
  14. docker_task_1/dynamic-network-architectures/README.md +14 -0
  15. docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/PKG-INFO +16 -0
  16. docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/SOURCES.txt +27 -0
  17. docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/dependency_links.txt +1 -0
  18. docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/not-zip-safe +1 -0
  19. docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/requires.txt +2 -0
  20. docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/top_level.txt +1 -0
  21. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/__init__.py +0 -0
  22. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/__pycache__/__init__.cpython-310.pyc +0 -0
  23. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/__pycache__/__init__.cpython-312.pyc +0 -0
  24. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__init__.py +0 -0
  25. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__pycache__/__init__.cpython-310.pyc +0 -0
  26. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__pycache__/__init__.cpython-312.pyc +0 -0
  27. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__pycache__/unet.cpython-310.pyc +0 -0
  28. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__pycache__/unet.cpython-312.pyc +0 -0
  29. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/resnet.py +236 -0
  30. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/unet.py +232 -0
  31. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/vgg.py +85 -0
  32. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__init__.py +0 -0
  33. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/__init__.cpython-310.pyc +0 -0
  34. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/__init__.cpython-312.pyc +0 -0
  35. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/helper.cpython-310.pyc +0 -0
  36. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/helper.cpython-312.pyc +0 -0
  37. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/plain_conv_encoder.cpython-310.pyc +0 -0
  38. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/plain_conv_encoder.cpython-312.pyc +0 -0
  39. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/regularization.cpython-310.pyc +0 -0
  40. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/regularization.cpython-312.pyc +0 -0
  41. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/residual.cpython-310.pyc +0 -0
  42. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/residual.cpython-312.pyc +0 -0
  43. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/residual_encoders.cpython-310.pyc +0 -0
  44. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/residual_encoders.cpython-312.pyc +0 -0
  45. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/simple_conv_blocks.cpython-310.pyc +0 -0
  46. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/simple_conv_blocks.cpython-312.pyc +0 -0
  47. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/unet_decoder.cpython-310.pyc +0 -0
  48. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/unet_decoder.cpython-312.pyc +0 -0
  49. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/unet_decoder_upsample_nearest.cpython-310.pyc +0 -0
  50. docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/unet_decoder_upsample_nearest.cpython-312.pyc +0 -0
.gitattributes CHANGED
@@ -33,3 +33,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ docker_task_1/nnsyn/documentation/assets/amos2022_sparseseg10.png filter=lfs diff=lfs merge=lfs -text
37
+ docker_task_1/nnsyn/documentation/assets/amos2022_sparseseg10_2d.png filter=lfs diff=lfs merge=lfs -text
38
+ docker_task_1/nnsyn/documentation/assets/nnU-Net_overview.png filter=lfs diff=lfs merge=lfs -text
39
+ docker_task_1/nnsyn/documentation/assets/regions_vs_labels.png filter=lfs diff=lfs merge=lfs -text
40
+ docker_task_1/nnsyn/documentation/assets/scribble_example.png filter=lfs diff=lfs merge=lfs -text
41
+ docker_task_2/nnsyn/documentation/assets/amos2022_sparseseg10.png filter=lfs diff=lfs merge=lfs -text
42
+ docker_task_2/nnsyn/documentation/assets/amos2022_sparseseg10_2d.png filter=lfs diff=lfs merge=lfs -text
43
+ docker_task_2/nnsyn/documentation/assets/nnU-Net_overview.png filter=lfs diff=lfs merge=lfs -text
44
+ docker_task_2/nnsyn/documentation/assets/regions_vs_labels.png filter=lfs diff=lfs merge=lfs -text
45
+ docker_task_2/nnsyn/documentation/assets/scribble_example.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +0,0 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
docker_task_1/.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ TASK_TYPE="mri" # Set to mri (Task 1) or cbct (Task 2)
2
+ INPUT_FOLDER="/input" # Do not change unless you want to test locally
docker_task_1/260_gt_nnUNetResEncUNetLPlans.json ADDED
@@ -0,0 +1,521 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dataset_name": "Dataset261_synthrad2025_task1_CT_AB_pre_v2r_stitched_masked",
3
+ "plans_name": "nnUNetResEncUNetLPlans",
4
+ "original_median_spacing_after_transp": [
5
+ 3.0,
6
+ 1.0,
7
+ 1.0
8
+ ],
9
+ "original_median_shape_after_transp": [
10
+ 99,
11
+ 442,
12
+ 465
13
+ ],
14
+ "image_reader_writer": "SimpleITKIO",
15
+ "transpose_forward": [
16
+ 0,
17
+ 1,
18
+ 2
19
+ ],
20
+ "transpose_backward": [
21
+ 0,
22
+ 1,
23
+ 2
24
+ ],
25
+ "configurations": {
26
+ "2d": {
27
+ "data_identifier": "nnUNetPlans_2d",
28
+ "preprocessor_name": "DefaultPreprocessor",
29
+ "batch_size": 13,
30
+ "patch_size": [
31
+ 448,
32
+ 512
33
+ ],
34
+ "median_image_size_in_voxels": [
35
+ 442.0,
36
+ 465.0
37
+ ],
38
+ "spacing": [
39
+ 1.0,
40
+ 1.0
41
+ ],
42
+ "normalization_schemes": [
43
+ "CTNormalizationClippingSynthrad2025"
44
+ ],
45
+ "use_mask_for_norm": [
46
+ false
47
+ ],
48
+ "resampling_fn_data": "resample_data_or_seg_to_shape",
49
+ "resampling_fn_seg": "resample_data_or_seg_to_shape",
50
+ "resampling_fn_data_kwargs": {
51
+ "is_seg": false,
52
+ "order": 3,
53
+ "order_z": 0,
54
+ "force_separate_z": null
55
+ },
56
+ "resampling_fn_seg_kwargs": {
57
+ "is_seg": true,
58
+ "order": 1,
59
+ "order_z": 0,
60
+ "force_separate_z": null
61
+ },
62
+ "resampling_fn_probabilities": "resample_data_or_seg_to_shape",
63
+ "resampling_fn_probabilities_kwargs": {
64
+ "is_seg": false,
65
+ "order": 1,
66
+ "order_z": 0,
67
+ "force_separate_z": null
68
+ },
69
+ "architecture": {
70
+ "network_class_name": "dynamic_network_architectures.architectures.unet.ResidualEncoderUNet",
71
+ "arch_kwargs": {
72
+ "n_stages": 7,
73
+ "features_per_stage": [
74
+ 32,
75
+ 64,
76
+ 128,
77
+ 256,
78
+ 512,
79
+ 512,
80
+ 512
81
+ ],
82
+ "conv_op": "torch.nn.modules.conv.Conv2d",
83
+ "kernel_sizes": [
84
+ [
85
+ 3,
86
+ 3
87
+ ],
88
+ [
89
+ 3,
90
+ 3
91
+ ],
92
+ [
93
+ 3,
94
+ 3
95
+ ],
96
+ [
97
+ 3,
98
+ 3
99
+ ],
100
+ [
101
+ 3,
102
+ 3
103
+ ],
104
+ [
105
+ 3,
106
+ 3
107
+ ],
108
+ [
109
+ 3,
110
+ 3
111
+ ]
112
+ ],
113
+ "strides": [
114
+ [
115
+ 1,
116
+ 1
117
+ ],
118
+ [
119
+ 2,
120
+ 2
121
+ ],
122
+ [
123
+ 2,
124
+ 2
125
+ ],
126
+ [
127
+ 2,
128
+ 2
129
+ ],
130
+ [
131
+ 2,
132
+ 2
133
+ ],
134
+ [
135
+ 2,
136
+ 2
137
+ ],
138
+ [
139
+ 2,
140
+ 2
141
+ ]
142
+ ],
143
+ "n_blocks_per_stage": [
144
+ 1,
145
+ 3,
146
+ 4,
147
+ 6,
148
+ 6,
149
+ 6,
150
+ 6
151
+ ],
152
+ "n_conv_per_stage_decoder": [
153
+ 1,
154
+ 1,
155
+ 1,
156
+ 1,
157
+ 1,
158
+ 1
159
+ ],
160
+ "conv_bias": true,
161
+ "norm_op": "torch.nn.modules.instancenorm.InstanceNorm2d",
162
+ "norm_op_kwargs": {
163
+ "eps": 1e-05,
164
+ "affine": true
165
+ },
166
+ "dropout_op": null,
167
+ "dropout_op_kwargs": null,
168
+ "nonlin": "torch.nn.LeakyReLU",
169
+ "nonlin_kwargs": {
170
+ "inplace": true
171
+ }
172
+ },
173
+ "_kw_requires_import": [
174
+ "conv_op",
175
+ "norm_op",
176
+ "dropout_op",
177
+ "nonlin"
178
+ ]
179
+ },
180
+ "batch_dice": true
181
+ },
182
+ "3d_lowres": {
183
+ "data_identifier": "nnUNetResEncUNetLPlans_3d_lowres",
184
+ "preprocessor_name": "DefaultPreprocessor",
185
+ "batch_size": 2,
186
+ "patch_size": [
187
+ 64,
188
+ 192,
189
+ 192
190
+ ],
191
+ "median_image_size_in_voxels": [
192
+ 99,
193
+ 292,
194
+ 307
195
+ ],
196
+ "spacing": [
197
+ 3.0,
198
+ 1.512589724855112,
199
+ 1.512589724855112
200
+ ],
201
+ "normalization_schemes": [
202
+ "CTNormalizationClippingSynthrad2025"
203
+ ],
204
+ "use_mask_for_norm": [
205
+ false
206
+ ],
207
+ "resampling_fn_data": "resample_data_or_seg_to_shape",
208
+ "resampling_fn_seg": "resample_data_or_seg_to_shape",
209
+ "resampling_fn_data_kwargs": {
210
+ "is_seg": false,
211
+ "order": 3,
212
+ "order_z": 0,
213
+ "force_separate_z": null
214
+ },
215
+ "resampling_fn_seg_kwargs": {
216
+ "is_seg": true,
217
+ "order": 1,
218
+ "order_z": 0,
219
+ "force_separate_z": null
220
+ },
221
+ "resampling_fn_probabilities": "resample_data_or_seg_to_shape",
222
+ "resampling_fn_probabilities_kwargs": {
223
+ "is_seg": false,
224
+ "order": 1,
225
+ "order_z": 0,
226
+ "force_separate_z": null
227
+ },
228
+ "architecture": {
229
+ "network_class_name": "dynamic_network_architectures.architectures.unet.ResidualEncoderUNet",
230
+ "arch_kwargs": {
231
+ "n_stages": 6,
232
+ "features_per_stage": [
233
+ 32,
234
+ 64,
235
+ 128,
236
+ 256,
237
+ 320,
238
+ 320
239
+ ],
240
+ "conv_op": "torch.nn.modules.conv.Conv3d",
241
+ "kernel_sizes": [
242
+ [
243
+ 3,
244
+ 3,
245
+ 3
246
+ ],
247
+ [
248
+ 3,
249
+ 3,
250
+ 3
251
+ ],
252
+ [
253
+ 3,
254
+ 3,
255
+ 3
256
+ ],
257
+ [
258
+ 3,
259
+ 3,
260
+ 3
261
+ ],
262
+ [
263
+ 3,
264
+ 3,
265
+ 3
266
+ ],
267
+ [
268
+ 3,
269
+ 3,
270
+ 3
271
+ ]
272
+ ],
273
+ "strides": [
274
+ [
275
+ 1,
276
+ 1,
277
+ 1
278
+ ],
279
+ [
280
+ 2,
281
+ 2,
282
+ 2
283
+ ],
284
+ [
285
+ 2,
286
+ 2,
287
+ 2
288
+ ],
289
+ [
290
+ 2,
291
+ 2,
292
+ 2
293
+ ],
294
+ [
295
+ 2,
296
+ 2,
297
+ 2
298
+ ],
299
+ [
300
+ 1,
301
+ 2,
302
+ 2
303
+ ]
304
+ ],
305
+ "n_blocks_per_stage": [
306
+ 1,
307
+ 3,
308
+ 4,
309
+ 6,
310
+ 6,
311
+ 6
312
+ ],
313
+ "n_conv_per_stage_decoder": [
314
+ 1,
315
+ 1,
316
+ 1,
317
+ 1,
318
+ 1
319
+ ],
320
+ "conv_bias": true,
321
+ "norm_op": "torch.nn.modules.instancenorm.InstanceNorm3d",
322
+ "norm_op_kwargs": {
323
+ "eps": 1e-05,
324
+ "affine": true
325
+ },
326
+ "dropout_op": null,
327
+ "dropout_op_kwargs": null,
328
+ "nonlin": "torch.nn.LeakyReLU",
329
+ "nonlin_kwargs": {
330
+ "inplace": true
331
+ }
332
+ },
333
+ "_kw_requires_import": [
334
+ "conv_op",
335
+ "norm_op",
336
+ "dropout_op",
337
+ "nonlin"
338
+ ]
339
+ },
340
+ "batch_dice": false,
341
+ "next_stage": "3d_cascade_fullres"
342
+ },
343
+ "3d_fullres": {
344
+ "data_identifier": "nnUNetPlans_3d_fullres",
345
+ "preprocessor_name": "DefaultPreprocessor",
346
+ "batch_size": 2,
347
+ "patch_size": [
348
+ 40,
349
+ 192,
350
+ 224
351
+ ],
352
+ "median_image_size_in_voxels": [
353
+ 99.0,
354
+ 442.0,
355
+ 465.0
356
+ ],
357
+ "spacing": [
358
+ 3.0,
359
+ 1.0,
360
+ 1.0
361
+ ],
362
+ "normalization_schemes": [
363
+ "CTNormalizationClippingSynthrad2025"
364
+ ],
365
+ "use_mask_for_norm": [
366
+ false
367
+ ],
368
+ "resampling_fn_data": "resample_data_or_seg_to_shape",
369
+ "resampling_fn_seg": "resample_data_or_seg_to_shape",
370
+ "resampling_fn_data_kwargs": {
371
+ "is_seg": false,
372
+ "order": 3,
373
+ "order_z": 0,
374
+ "force_separate_z": null
375
+ },
376
+ "resampling_fn_seg_kwargs": {
377
+ "is_seg": true,
378
+ "order": 1,
379
+ "order_z": 0,
380
+ "force_separate_z": null
381
+ },
382
+ "resampling_fn_probabilities": "resample_data_or_seg_to_shape",
383
+ "resampling_fn_probabilities_kwargs": {
384
+ "is_seg": false,
385
+ "order": 1,
386
+ "order_z": 0,
387
+ "force_separate_z": null
388
+ },
389
+ "architecture": {
390
+ "network_class_name": "dynamic_network_architectures.architectures.unet.ResidualEncoderUNet",
391
+ "arch_kwargs": {
392
+ "n_stages": 6,
393
+ "features_per_stage": [
394
+ 32,
395
+ 64,
396
+ 128,
397
+ 256,
398
+ 320,
399
+ 320
400
+ ],
401
+ "conv_op": "torch.nn.modules.conv.Conv3d",
402
+ "kernel_sizes": [
403
+ [
404
+ 1,
405
+ 3,
406
+ 3
407
+ ],
408
+ [
409
+ 3,
410
+ 3,
411
+ 3
412
+ ],
413
+ [
414
+ 3,
415
+ 3,
416
+ 3
417
+ ],
418
+ [
419
+ 3,
420
+ 3,
421
+ 3
422
+ ],
423
+ [
424
+ 3,
425
+ 3,
426
+ 3
427
+ ],
428
+ [
429
+ 3,
430
+ 3,
431
+ 3
432
+ ]
433
+ ],
434
+ "strides": [
435
+ [
436
+ 1,
437
+ 1,
438
+ 1
439
+ ],
440
+ [
441
+ 1,
442
+ 2,
443
+ 2
444
+ ],
445
+ [
446
+ 2,
447
+ 2,
448
+ 2
449
+ ],
450
+ [
451
+ 2,
452
+ 2,
453
+ 2
454
+ ],
455
+ [
456
+ 2,
457
+ 2,
458
+ 2
459
+ ],
460
+ [
461
+ 1,
462
+ 2,
463
+ 2
464
+ ]
465
+ ],
466
+ "n_blocks_per_stage": [
467
+ 1,
468
+ 3,
469
+ 4,
470
+ 6,
471
+ 6,
472
+ 6
473
+ ],
474
+ "n_conv_per_stage_decoder": [
475
+ 1,
476
+ 1,
477
+ 1,
478
+ 1,
479
+ 1
480
+ ],
481
+ "conv_bias": true,
482
+ "norm_op": "torch.nn.modules.instancenorm.InstanceNorm3d",
483
+ "norm_op_kwargs": {
484
+ "eps": 1e-05,
485
+ "affine": true
486
+ },
487
+ "dropout_op": null,
488
+ "dropout_op_kwargs": null,
489
+ "nonlin": "torch.nn.LeakyReLU",
490
+ "nonlin_kwargs": {
491
+ "inplace": true
492
+ }
493
+ },
494
+ "_kw_requires_import": [
495
+ "conv_op",
496
+ "norm_op",
497
+ "dropout_op",
498
+ "nonlin"
499
+ ]
500
+ },
501
+ "batch_dice": true
502
+ },
503
+ "3d_cascade_fullres": {
504
+ "inherits_from": "3d_fullres",
505
+ "previous_stage": "3d_lowres"
506
+ }
507
+ },
508
+ "experiment_planner_used": "nnUNetPlannerResEncL",
509
+ "label_manager": "LabelManager",
510
+ "foreground_intensity_properties_per_channel": {
511
+ "0": {
512
+ "max": 3958.0,
513
+ "mean": -226.3246612548828,
514
+ "median": -81.0,
515
+ "min": -1502.0,
516
+ "percentile_00_5": -1024.0,
517
+ "percentile_99_5": 566.0,
518
+ "std": 396.30517578125
519
+ }
520
+ }
521
+ }
docker_task_1/262_gt_nnUNetResEncUNetLPlans.json ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dataset_name": "Dataset263_synthrad2025_task1_CT_HN_pre_v2r_stitched_masked",
3
+ "plans_name": "nnUNetResEncUNetLPlans",
4
+ "original_median_spacing_after_transp": [
5
+ 3.0,
6
+ 1.0,
7
+ 1.0
8
+ ],
9
+ "original_median_shape_after_transp": [
10
+ 89,
11
+ 296,
12
+ 279
13
+ ],
14
+ "image_reader_writer": "SimpleITKIO",
15
+ "transpose_forward": [
16
+ 0,
17
+ 1,
18
+ 2
19
+ ],
20
+ "transpose_backward": [
21
+ 0,
22
+ 1,
23
+ 2
24
+ ],
25
+ "configurations": {
26
+ "2d": {
27
+ "data_identifier": "nnUNetPlans_2d",
28
+ "preprocessor_name": "DefaultPreprocessor",
29
+ "batch_size": 30,
30
+ "patch_size": [
31
+ 320,
32
+ 320
33
+ ],
34
+ "median_image_size_in_voxels": [
35
+ 296.0,
36
+ 279.0
37
+ ],
38
+ "spacing": [
39
+ 1.0,
40
+ 1.0
41
+ ],
42
+ "normalization_schemes": [
43
+ "CTNormalizationClippingSynthrad2025"
44
+ ],
45
+ "use_mask_for_norm": [
46
+ false
47
+ ],
48
+ "resampling_fn_data": "resample_data_or_seg_to_shape",
49
+ "resampling_fn_seg": "resample_data_or_seg_to_shape",
50
+ "resampling_fn_data_kwargs": {
51
+ "is_seg": false,
52
+ "order": 3,
53
+ "order_z": 0,
54
+ "force_separate_z": null
55
+ },
56
+ "resampling_fn_seg_kwargs": {
57
+ "is_seg": true,
58
+ "order": 1,
59
+ "order_z": 0,
60
+ "force_separate_z": null
61
+ },
62
+ "resampling_fn_probabilities": "resample_data_or_seg_to_shape",
63
+ "resampling_fn_probabilities_kwargs": {
64
+ "is_seg": false,
65
+ "order": 1,
66
+ "order_z": 0,
67
+ "force_separate_z": null
68
+ },
69
+ "architecture": {
70
+ "network_class_name": "dynamic_network_architectures.architectures.unet.ResidualEncoderUNet",
71
+ "arch_kwargs": {
72
+ "n_stages": 7,
73
+ "features_per_stage": [
74
+ 32,
75
+ 64,
76
+ 128,
77
+ 256,
78
+ 512,
79
+ 512,
80
+ 512
81
+ ],
82
+ "conv_op": "torch.nn.modules.conv.Conv2d",
83
+ "kernel_sizes": [
84
+ [
85
+ 3,
86
+ 3
87
+ ],
88
+ [
89
+ 3,
90
+ 3
91
+ ],
92
+ [
93
+ 3,
94
+ 3
95
+ ],
96
+ [
97
+ 3,
98
+ 3
99
+ ],
100
+ [
101
+ 3,
102
+ 3
103
+ ],
104
+ [
105
+ 3,
106
+ 3
107
+ ],
108
+ [
109
+ 3,
110
+ 3
111
+ ]
112
+ ],
113
+ "strides": [
114
+ [
115
+ 1,
116
+ 1
117
+ ],
118
+ [
119
+ 2,
120
+ 2
121
+ ],
122
+ [
123
+ 2,
124
+ 2
125
+ ],
126
+ [
127
+ 2,
128
+ 2
129
+ ],
130
+ [
131
+ 2,
132
+ 2
133
+ ],
134
+ [
135
+ 2,
136
+ 2
137
+ ],
138
+ [
139
+ 2,
140
+ 2
141
+ ]
142
+ ],
143
+ "n_blocks_per_stage": [
144
+ 1,
145
+ 3,
146
+ 4,
147
+ 6,
148
+ 6,
149
+ 6,
150
+ 6
151
+ ],
152
+ "n_conv_per_stage_decoder": [
153
+ 1,
154
+ 1,
155
+ 1,
156
+ 1,
157
+ 1,
158
+ 1
159
+ ],
160
+ "conv_bias": true,
161
+ "norm_op": "torch.nn.modules.instancenorm.InstanceNorm2d",
162
+ "norm_op_kwargs": {
163
+ "eps": 1e-05,
164
+ "affine": true
165
+ },
166
+ "dropout_op": null,
167
+ "dropout_op_kwargs": null,
168
+ "nonlin": "torch.nn.LeakyReLU",
169
+ "nonlin_kwargs": {
170
+ "inplace": true
171
+ }
172
+ },
173
+ "_kw_requires_import": [
174
+ "conv_op",
175
+ "norm_op",
176
+ "dropout_op",
177
+ "nonlin"
178
+ ]
179
+ },
180
+ "batch_dice": true
181
+ },
182
+ "3d_fullres": {
183
+ "data_identifier": "nnUNetPlans_3d_fullres",
184
+ "preprocessor_name": "DefaultPreprocessor",
185
+ "batch_size": 2,
186
+ "patch_size": [
187
+ 56,
188
+ 192,
189
+ 160
190
+ ],
191
+ "median_image_size_in_voxels": [
192
+ 89.0,
193
+ 296.0,
194
+ 279.0
195
+ ],
196
+ "spacing": [
197
+ 3.0,
198
+ 1.0,
199
+ 1.0
200
+ ],
201
+ "normalization_schemes": [
202
+ "CTNormalizationClippingSynthrad2025"
203
+ ],
204
+ "use_mask_for_norm": [
205
+ false
206
+ ],
207
+ "resampling_fn_data": "resample_data_or_seg_to_shape",
208
+ "resampling_fn_seg": "resample_data_or_seg_to_shape",
209
+ "resampling_fn_data_kwargs": {
210
+ "is_seg": false,
211
+ "order": 3,
212
+ "order_z": 0,
213
+ "force_separate_z": null
214
+ },
215
+ "resampling_fn_seg_kwargs": {
216
+ "is_seg": true,
217
+ "order": 1,
218
+ "order_z": 0,
219
+ "force_separate_z": null
220
+ },
221
+ "resampling_fn_probabilities": "resample_data_or_seg_to_shape",
222
+ "resampling_fn_probabilities_kwargs": {
223
+ "is_seg": false,
224
+ "order": 1,
225
+ "order_z": 0,
226
+ "force_separate_z": null
227
+ },
228
+ "architecture": {
229
+ "network_class_name": "dynamic_network_architectures.architectures.unet.ResidualEncoderUNet",
230
+ "arch_kwargs": {
231
+ "n_stages": 6,
232
+ "features_per_stage": [
233
+ 32,
234
+ 64,
235
+ 128,
236
+ 256,
237
+ 320,
238
+ 320
239
+ ],
240
+ "conv_op": "torch.nn.modules.conv.Conv3d",
241
+ "kernel_sizes": [
242
+ [
243
+ 1,
244
+ 3,
245
+ 3
246
+ ],
247
+ [
248
+ 3,
249
+ 3,
250
+ 3
251
+ ],
252
+ [
253
+ 3,
254
+ 3,
255
+ 3
256
+ ],
257
+ [
258
+ 3,
259
+ 3,
260
+ 3
261
+ ],
262
+ [
263
+ 3,
264
+ 3,
265
+ 3
266
+ ],
267
+ [
268
+ 3,
269
+ 3,
270
+ 3
271
+ ]
272
+ ],
273
+ "strides": [
274
+ [
275
+ 1,
276
+ 1,
277
+ 1
278
+ ],
279
+ [
280
+ 1,
281
+ 2,
282
+ 2
283
+ ],
284
+ [
285
+ 2,
286
+ 2,
287
+ 2
288
+ ],
289
+ [
290
+ 2,
291
+ 2,
292
+ 2
293
+ ],
294
+ [
295
+ 2,
296
+ 2,
297
+ 2
298
+ ],
299
+ [
300
+ 1,
301
+ 2,
302
+ 2
303
+ ]
304
+ ],
305
+ "n_blocks_per_stage": [
306
+ 1,
307
+ 3,
308
+ 4,
309
+ 6,
310
+ 6,
311
+ 6
312
+ ],
313
+ "n_conv_per_stage_decoder": [
314
+ 1,
315
+ 1,
316
+ 1,
317
+ 1,
318
+ 1
319
+ ],
320
+ "conv_bias": true,
321
+ "norm_op": "torch.nn.modules.instancenorm.InstanceNorm3d",
322
+ "norm_op_kwargs": {
323
+ "eps": 1e-05,
324
+ "affine": true
325
+ },
326
+ "dropout_op": null,
327
+ "dropout_op_kwargs": null,
328
+ "nonlin": "torch.nn.LeakyReLU",
329
+ "nonlin_kwargs": {
330
+ "inplace": true
331
+ }
332
+ },
333
+ "_kw_requires_import": [
334
+ "conv_op",
335
+ "norm_op",
336
+ "dropout_op",
337
+ "nonlin"
338
+ ]
339
+ },
340
+ "batch_dice": false
341
+ }
342
+ },
343
+ "experiment_planner_used": "nnUNetPlannerResEncL",
344
+ "label_manager": "LabelManager",
345
+ "foreground_intensity_properties_per_channel": {
346
+ "0": {
347
+ "max": 3940.0,
348
+ "mean": -137.8296356201172,
349
+ "median": 12.0,
350
+ "min": -1708.0,
351
+ "percentile_00_5": -1018.0,
352
+ "percentile_99_5": 1349.0,
353
+ "std": 482.0824279785156
354
+ }
355
+ }
356
+ }
docker_task_1/264_gt_nnUNetResEncUNetLPlans.json ADDED
@@ -0,0 +1,521 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dataset_name": "Dataset265_synthrad2025_task1_CT_TH_pre_v2r_stitched_masked",
3
+ "plans_name": "nnUNetResEncUNetLPlans",
4
+ "original_median_spacing_after_transp": [
5
+ 3.0,
6
+ 1.0,
7
+ 1.0
8
+ ],
9
+ "original_median_shape_after_transp": [
10
+ 108,
11
+ 476,
12
+ 536
13
+ ],
14
+ "image_reader_writer": "SimpleITKIO",
15
+ "transpose_forward": [
16
+ 0,
17
+ 1,
18
+ 2
19
+ ],
20
+ "transpose_backward": [
21
+ 0,
22
+ 1,
23
+ 2
24
+ ],
25
+ "configurations": {
26
+ "2d": {
27
+ "data_identifier": "nnUNetPlans_2d",
28
+ "preprocessor_name": "DefaultPreprocessor",
29
+ "batch_size": 13,
30
+ "patch_size": [
31
+ 448,
32
+ 512
33
+ ],
34
+ "median_image_size_in_voxels": [
35
+ 476.0,
36
+ 536.0
37
+ ],
38
+ "spacing": [
39
+ 1.0,
40
+ 1.0
41
+ ],
42
+ "normalization_schemes": [
43
+ "CTNormalizationClippingSynthrad2025"
44
+ ],
45
+ "use_mask_for_norm": [
46
+ false
47
+ ],
48
+ "resampling_fn_data": "resample_data_or_seg_to_shape",
49
+ "resampling_fn_seg": "resample_data_or_seg_to_shape",
50
+ "resampling_fn_data_kwargs": {
51
+ "is_seg": false,
52
+ "order": 3,
53
+ "order_z": 0,
54
+ "force_separate_z": null
55
+ },
56
+ "resampling_fn_seg_kwargs": {
57
+ "is_seg": true,
58
+ "order": 1,
59
+ "order_z": 0,
60
+ "force_separate_z": null
61
+ },
62
+ "resampling_fn_probabilities": "resample_data_or_seg_to_shape",
63
+ "resampling_fn_probabilities_kwargs": {
64
+ "is_seg": false,
65
+ "order": 1,
66
+ "order_z": 0,
67
+ "force_separate_z": null
68
+ },
69
+ "architecture": {
70
+ "network_class_name": "dynamic_network_architectures.architectures.unet.ResidualEncoderUNet",
71
+ "arch_kwargs": {
72
+ "n_stages": 7,
73
+ "features_per_stage": [
74
+ 32,
75
+ 64,
76
+ 128,
77
+ 256,
78
+ 512,
79
+ 512,
80
+ 512
81
+ ],
82
+ "conv_op": "torch.nn.modules.conv.Conv2d",
83
+ "kernel_sizes": [
84
+ [
85
+ 3,
86
+ 3
87
+ ],
88
+ [
89
+ 3,
90
+ 3
91
+ ],
92
+ [
93
+ 3,
94
+ 3
95
+ ],
96
+ [
97
+ 3,
98
+ 3
99
+ ],
100
+ [
101
+ 3,
102
+ 3
103
+ ],
104
+ [
105
+ 3,
106
+ 3
107
+ ],
108
+ [
109
+ 3,
110
+ 3
111
+ ]
112
+ ],
113
+ "strides": [
114
+ [
115
+ 1,
116
+ 1
117
+ ],
118
+ [
119
+ 2,
120
+ 2
121
+ ],
122
+ [
123
+ 2,
124
+ 2
125
+ ],
126
+ [
127
+ 2,
128
+ 2
129
+ ],
130
+ [
131
+ 2,
132
+ 2
133
+ ],
134
+ [
135
+ 2,
136
+ 2
137
+ ],
138
+ [
139
+ 2,
140
+ 2
141
+ ]
142
+ ],
143
+ "n_blocks_per_stage": [
144
+ 1,
145
+ 3,
146
+ 4,
147
+ 6,
148
+ 6,
149
+ 6,
150
+ 6
151
+ ],
152
+ "n_conv_per_stage_decoder": [
153
+ 1,
154
+ 1,
155
+ 1,
156
+ 1,
157
+ 1,
158
+ 1
159
+ ],
160
+ "conv_bias": true,
161
+ "norm_op": "torch.nn.modules.instancenorm.InstanceNorm2d",
162
+ "norm_op_kwargs": {
163
+ "eps": 1e-05,
164
+ "affine": true
165
+ },
166
+ "dropout_op": null,
167
+ "dropout_op_kwargs": null,
168
+ "nonlin": "torch.nn.LeakyReLU",
169
+ "nonlin_kwargs": {
170
+ "inplace": true
171
+ }
172
+ },
173
+ "_kw_requires_import": [
174
+ "conv_op",
175
+ "norm_op",
176
+ "dropout_op",
177
+ "nonlin"
178
+ ]
179
+ },
180
+ "batch_dice": true
181
+ },
182
+ "3d_lowres": {
183
+ "data_identifier": "nnUNetResEncUNetLPlans_3d_lowres",
184
+ "preprocessor_name": "DefaultPreprocessor",
185
+ "batch_size": 2,
186
+ "patch_size": [
187
+ 64,
188
+ 192,
189
+ 192
190
+ ],
191
+ "median_image_size_in_voxels": [
192
+ 98,
193
+ 288,
194
+ 324
195
+ ],
196
+ "spacing": [
197
+ 3.278181,
198
+ 1.652847632271752,
199
+ 1.652847632271752
200
+ ],
201
+ "normalization_schemes": [
202
+ "CTNormalizationClippingSynthrad2025"
203
+ ],
204
+ "use_mask_for_norm": [
205
+ false
206
+ ],
207
+ "resampling_fn_data": "resample_data_or_seg_to_shape",
208
+ "resampling_fn_seg": "resample_data_or_seg_to_shape",
209
+ "resampling_fn_data_kwargs": {
210
+ "is_seg": false,
211
+ "order": 3,
212
+ "order_z": 0,
213
+ "force_separate_z": null
214
+ },
215
+ "resampling_fn_seg_kwargs": {
216
+ "is_seg": true,
217
+ "order": 1,
218
+ "order_z": 0,
219
+ "force_separate_z": null
220
+ },
221
+ "resampling_fn_probabilities": "resample_data_or_seg_to_shape",
222
+ "resampling_fn_probabilities_kwargs": {
223
+ "is_seg": false,
224
+ "order": 1,
225
+ "order_z": 0,
226
+ "force_separate_z": null
227
+ },
228
+ "architecture": {
229
+ "network_class_name": "dynamic_network_architectures.architectures.unet.ResidualEncoderUNet",
230
+ "arch_kwargs": {
231
+ "n_stages": 6,
232
+ "features_per_stage": [
233
+ 32,
234
+ 64,
235
+ 128,
236
+ 256,
237
+ 320,
238
+ 320
239
+ ],
240
+ "conv_op": "torch.nn.modules.conv.Conv3d",
241
+ "kernel_sizes": [
242
+ [
243
+ 3,
244
+ 3,
245
+ 3
246
+ ],
247
+ [
248
+ 3,
249
+ 3,
250
+ 3
251
+ ],
252
+ [
253
+ 3,
254
+ 3,
255
+ 3
256
+ ],
257
+ [
258
+ 3,
259
+ 3,
260
+ 3
261
+ ],
262
+ [
263
+ 3,
264
+ 3,
265
+ 3
266
+ ],
267
+ [
268
+ 3,
269
+ 3,
270
+ 3
271
+ ]
272
+ ],
273
+ "strides": [
274
+ [
275
+ 1,
276
+ 1,
277
+ 1
278
+ ],
279
+ [
280
+ 2,
281
+ 2,
282
+ 2
283
+ ],
284
+ [
285
+ 2,
286
+ 2,
287
+ 2
288
+ ],
289
+ [
290
+ 2,
291
+ 2,
292
+ 2
293
+ ],
294
+ [
295
+ 2,
296
+ 2,
297
+ 2
298
+ ],
299
+ [
300
+ 1,
301
+ 2,
302
+ 2
303
+ ]
304
+ ],
305
+ "n_blocks_per_stage": [
306
+ 1,
307
+ 3,
308
+ 4,
309
+ 6,
310
+ 6,
311
+ 6
312
+ ],
313
+ "n_conv_per_stage_decoder": [
314
+ 1,
315
+ 1,
316
+ 1,
317
+ 1,
318
+ 1
319
+ ],
320
+ "conv_bias": true,
321
+ "norm_op": "torch.nn.modules.instancenorm.InstanceNorm3d",
322
+ "norm_op_kwargs": {
323
+ "eps": 1e-05,
324
+ "affine": true
325
+ },
326
+ "dropout_op": null,
327
+ "dropout_op_kwargs": null,
328
+ "nonlin": "torch.nn.LeakyReLU",
329
+ "nonlin_kwargs": {
330
+ "inplace": true
331
+ }
332
+ },
333
+ "_kw_requires_import": [
334
+ "conv_op",
335
+ "norm_op",
336
+ "dropout_op",
337
+ "nonlin"
338
+ ]
339
+ },
340
+ "batch_dice": false,
341
+ "next_stage": "3d_cascade_fullres"
342
+ },
343
+ "3d_fullres": {
344
+ "data_identifier": "nnUNetPlans_3d_fullres",
345
+ "preprocessor_name": "DefaultPreprocessor",
346
+ "batch_size": 2,
347
+ "patch_size": [
348
+ 40,
349
+ 192,
350
+ 224
351
+ ],
352
+ "median_image_size_in_voxels": [
353
+ 107.5,
354
+ 476.0,
355
+ 536.0
356
+ ],
357
+ "spacing": [
358
+ 3.0,
359
+ 1.0,
360
+ 1.0
361
+ ],
362
+ "normalization_schemes": [
363
+ "CTNormalizationClippingSynthrad2025"
364
+ ],
365
+ "use_mask_for_norm": [
366
+ false
367
+ ],
368
+ "resampling_fn_data": "resample_data_or_seg_to_shape",
369
+ "resampling_fn_seg": "resample_data_or_seg_to_shape",
370
+ "resampling_fn_data_kwargs": {
371
+ "is_seg": false,
372
+ "order": 3,
373
+ "order_z": 0,
374
+ "force_separate_z": null
375
+ },
376
+ "resampling_fn_seg_kwargs": {
377
+ "is_seg": true,
378
+ "order": 1,
379
+ "order_z": 0,
380
+ "force_separate_z": null
381
+ },
382
+ "resampling_fn_probabilities": "resample_data_or_seg_to_shape",
383
+ "resampling_fn_probabilities_kwargs": {
384
+ "is_seg": false,
385
+ "order": 1,
386
+ "order_z": 0,
387
+ "force_separate_z": null
388
+ },
389
+ "architecture": {
390
+ "network_class_name": "dynamic_network_architectures.architectures.unet.ResidualEncoderUNet",
391
+ "arch_kwargs": {
392
+ "n_stages": 6,
393
+ "features_per_stage": [
394
+ 32,
395
+ 64,
396
+ 128,
397
+ 256,
398
+ 320,
399
+ 320
400
+ ],
401
+ "conv_op": "torch.nn.modules.conv.Conv3d",
402
+ "kernel_sizes": [
403
+ [
404
+ 1,
405
+ 3,
406
+ 3
407
+ ],
408
+ [
409
+ 3,
410
+ 3,
411
+ 3
412
+ ],
413
+ [
414
+ 3,
415
+ 3,
416
+ 3
417
+ ],
418
+ [
419
+ 3,
420
+ 3,
421
+ 3
422
+ ],
423
+ [
424
+ 3,
425
+ 3,
426
+ 3
427
+ ],
428
+ [
429
+ 3,
430
+ 3,
431
+ 3
432
+ ]
433
+ ],
434
+ "strides": [
435
+ [
436
+ 1,
437
+ 1,
438
+ 1
439
+ ],
440
+ [
441
+ 1,
442
+ 2,
443
+ 2
444
+ ],
445
+ [
446
+ 2,
447
+ 2,
448
+ 2
449
+ ],
450
+ [
451
+ 2,
452
+ 2,
453
+ 2
454
+ ],
455
+ [
456
+ 2,
457
+ 2,
458
+ 2
459
+ ],
460
+ [
461
+ 1,
462
+ 2,
463
+ 2
464
+ ]
465
+ ],
466
+ "n_blocks_per_stage": [
467
+ 1,
468
+ 3,
469
+ 4,
470
+ 6,
471
+ 6,
472
+ 6
473
+ ],
474
+ "n_conv_per_stage_decoder": [
475
+ 1,
476
+ 1,
477
+ 1,
478
+ 1,
479
+ 1
480
+ ],
481
+ "conv_bias": true,
482
+ "norm_op": "torch.nn.modules.instancenorm.InstanceNorm3d",
483
+ "norm_op_kwargs": {
484
+ "eps": 1e-05,
485
+ "affine": true
486
+ },
487
+ "dropout_op": null,
488
+ "dropout_op_kwargs": null,
489
+ "nonlin": "torch.nn.LeakyReLU",
490
+ "nonlin_kwargs": {
491
+ "inplace": true
492
+ }
493
+ },
494
+ "_kw_requires_import": [
495
+ "conv_op",
496
+ "norm_op",
497
+ "dropout_op",
498
+ "nonlin"
499
+ ]
500
+ },
501
+ "batch_dice": true
502
+ },
503
+ "3d_cascade_fullres": {
504
+ "inherits_from": "3d_fullres",
505
+ "previous_stage": "3d_lowres"
506
+ }
507
+ },
508
+ "experiment_planner_used": "nnUNetPlannerResEncL",
509
+ "label_manager": "LabelManager",
510
+ "foreground_intensity_properties_per_channel": {
511
+ "0": {
512
+ "max": 3867.0,
513
+ "mean": -282.4960632324219,
514
+ "median": -94.0,
515
+ "min": -1607.0,
516
+ "percentile_00_5": -1024.0,
517
+ "percentile_99_5": 630.0,
518
+ "std": 427.12237548828125
519
+ }
520
+ }
521
+ }
docker_task_1/Dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+ # FROM python:3.12
3
+ ARG task_type
4
+
5
+ ENV TASK_TYPE=$task_type
6
+ ENV EXECUTE_IN_DOCKER=1
7
+
8
+ RUN groupadd -r algorithm && useradd -m --no-log-init -r -g algorithm algorithm
9
+
10
+ RUN mkdir -p /opt/algorithm /input /output \
11
+ && chown algorithm:algorithm /opt/algorithm /input /output
12
+
13
+ USER algorithm
14
+
15
+ WORKDIR /opt/algorithm
16
+
17
+ ENV PATH="/home/algorithm/.local/bin:${PATH}"
18
+ # ENV nnUNet_preprocessed="/opt/algorithm/nnunet_preprocessed"
19
+ # ENV nnUNet_results="/opt/algorithm/nnunet_results"
20
+ # ENV nnUNet_raw="/opt/algorithm/nnunet_raw"
21
+ # ENV PYTHONPATH="/opt/algorithm/nnUNetv2:$PYTHONPATH"
22
+
23
+ RUN python -m pip install --user -U pip
24
+
25
+
26
+ COPY --chown=algorithm:algorithm requirements.txt /opt/algorithm/
27
+ RUN python -m pip install --user -r requirements.txt
28
+ COPY --chown=algorithm:algorithm nnsyn /opt/algorithm/nnsyn
29
+ RUN cd /opt/algorithm/nnsyn && python -m pip install --user -e .
30
+
31
+ COPY --chown=algorithm:algorithm .env /opt/algorithm/
32
+ COPY --chown=algorithm:algorithm process.py /opt/algorithm/
33
+ COPY --chown=algorithm:algorithm base_algorithm.py /opt/algorithm/
34
+ COPY --chown=algorithm:algorithm nnunet_preprocessed/ /opt/algorithm/nnunet_preprocessed
35
+ COPY --chown=algorithm:algorithm nnunet_raw/ /opt/algorithm/nnunet_raw
36
+ # COPY --chown=algorithm:algorithm nnunet_results/ /opt/algorithm/nnunet_results
37
+ COPY --chown=algorithm:algorithm 260_gt_nnUNetResEncUNetLPlans.json /opt/algorithm/
38
+ COPY --chown=algorithm:algorithm 262_gt_nnUNetResEncUNetLPlans.json /opt/algorithm/
39
+ COPY --chown=algorithm:algorithm 264_gt_nnUNetResEncUNetLPlans.json /opt/algorithm/
40
+ COPY --chown=algorithm:algorithm revert_normalisation.py /opt/algorithm/
41
+ COPY --chown=algorithm:algorithm dynamic-network-architectures/ /opt/algorithm/dynamic-network-architectures
42
+ RUN cd /opt/algorithm/dynamic-network-architectures && python -m pip install --user -e .
43
+ ENTRYPOINT python -m process $0 $@
docker_task_1/__pycache__/base_algorithm.cpython-312.pyc ADDED
Binary file (9.47 kB). View file
 
docker_task_1/__pycache__/revert_normalisation.cpython-312.pyc ADDED
Binary file (7.56 kB). View file
 
docker_task_1/base_algorithm.py ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import logging
3
+ import os
4
+ import re
5
+ from abc import ABC, abstractmethod
6
+ from pathlib import Path
7
+ from typing import (Any, Callable, Dict, Iterable, List, Optional, Pattern,
8
+ Set, Tuple, Union)
9
+
10
+ import numpy as np
11
+ import SimpleITK
12
+ from evalutils.exceptions import FileLoaderError
13
+ from evalutils.io import FileLoader, ImageLoader, SimpleITKLoader
14
+ from evalutils.validators import (UniqueImagesValidator,
15
+ UniquePathIndicesValidator)
16
+ from pandas import DataFrame
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+ # Check if .env file exists and load it
21
+ if Path(".env").exists():
22
+ from dotenv import dotenv_values
23
+
24
+ config = dotenv_values(".env")
25
+
26
+ TASK_TYPE = config["TASK_TYPE"]
27
+ INPUT_FOLDER = config["INPUT_FOLDER"]
28
+
29
+ print("########## ENVIRONMENT VARIABLES ##########")
30
+ print(f"TASK_TYPE: {TASK_TYPE}")
31
+ print(f"INPUT_FOLDER: {INPUT_FOLDER}")
32
+ else:
33
+ TASK_TYPE = "mri"
34
+ INPUT_FOLDER = "/input"
35
+
36
+ if INPUT_FOLDER == "/input":
37
+ OUTPUT_FOLDER = "/output"
38
+ else:
39
+ OUTPUT_FOLDER = "./output"
40
+
41
+ DEFAULT_IMAGE_PATH = Path(f"{INPUT_FOLDER}/images/{TASK_TYPE}")
42
+ DEFAULT_REGION_PATH = Path(f"{INPUT_FOLDER}/region.json")
43
+ DEFAULT_MASK_PATH = Path(f"{INPUT_FOLDER}/images/body")
44
+ DEFAULT_OUTPUT_PATH = Path(f"{OUTPUT_FOLDER}/images/synthetic-ct")
45
+ DEFAULT_OUTPUT_FILE = Path(f"{OUTPUT_FOLDER}/results.json")
46
+
47
+
48
+ class BaseSynthradAlgorithm(ABC):
49
+ def __init__(
50
+ self,
51
+ input_path: Path = DEFAULT_IMAGE_PATH,
52
+ mask_path: Path = DEFAULT_MASK_PATH,
53
+ region_path: Path = DEFAULT_REGION_PATH,
54
+ output_path: Path = DEFAULT_OUTPUT_PATH,
55
+ output_file: Path = DEFAULT_OUTPUT_FILE,
56
+ validators: Optional[Dict[str, callable]] = None,
57
+ file_loader: FileLoader = SimpleITKLoader(),
58
+ ):
59
+ """
60
+ Parameters
61
+ ----------
62
+
63
+ input_path
64
+ The path in the container where the input images will be loaded from.
65
+ from. Default: `/input/images/mri/`
66
+ mask_path
67
+ The path in the container where the input masks will be loaded from.
68
+ Default: `/input/images/body/`
69
+ output_path
70
+ The path in the container where the output images will be written.
71
+ Default: `/output/images/synthetic-ct/`
72
+
73
+ output_file
74
+ The path to the location where the results will be written.
75
+ Default: `/output/results.json`
76
+ file_loader
77
+ The loaders that will be used to get all files.
78
+ Default: `evalutils.io.SimpleITKLoader` for `image` and `mask`
79
+ validators
80
+ A dictionary containing the validators that will be used on the
81
+ loaded data per file_loader key. Default:
82
+ `evalutils.validators.UniqueImagesValidator` for `input_image`
83
+ """
84
+
85
+ self._index_keys = ["image", "mask"]
86
+ self.input_path = input_path
87
+ self.mask_path = mask_path
88
+ self.region_path = region_path
89
+ self.output_path = output_path
90
+ self.output_file = output_file
91
+ self._file_loader = file_loader
92
+
93
+ # TODO: Add validators
94
+ # self.validators = [
95
+ # UniquePathIndicesValidator(),
96
+ # UniqueImagesValidator(),
97
+ # ]
98
+
99
+ self.cases = {}
100
+ self._case_results = []
101
+
102
+ def load(self):
103
+ self.images = self._load_cases(
104
+ folder=self.input_path, file_loader=self._file_loader
105
+ )
106
+
107
+ self.masks = self._load_cases(
108
+ folder=self.mask_path, file_loader=self._file_loader
109
+ )
110
+
111
+ with open(self.region_path, "r") as f:
112
+ self.region = json.load(f)
113
+
114
+ def _load_cases(
115
+ self,
116
+ folder: Path,
117
+ file_loader: ImageLoader,
118
+ ) -> DataFrame:
119
+ cases = []
120
+
121
+ for fp in sorted(folder.glob("*")):
122
+ try:
123
+ new_cases = file_loader.load(fname=fp)
124
+ except FileLoaderError:
125
+ logger.warning(f"Could not load {fp.name} using {file_loader}.")
126
+ else:
127
+ cases.extend(new_cases)
128
+
129
+ if len(cases) == 0:
130
+ raise FileLoaderError(
131
+ f"Could not load any files in {folder} with " f"{file_loader}."
132
+ )
133
+
134
+ return cases
135
+
136
+ def validate(self):
137
+ """TODO: Validates each dataframe for each fileloader separately"""
138
+ pass
139
+
140
+ def _validate_data_frame(self, df: DataFrame):
141
+ "TODO: Validate the dataframe for a specific fileloader"
142
+ pass
143
+
144
+ def process_cases(self):
145
+ self._case_results = []
146
+
147
+ for idx, case in enumerate(zip(self.images, self.masks)):
148
+ self._case_results.append(self.process_case(idx=idx, case=case))
149
+
150
+ def process_case(self, idx: int, case: List[DataFrame]) -> Dict:
151
+ images, images_file_paths = {}, {}
152
+
153
+ images["image"], images_file_paths["image"] = self._load_input_image(case[0])
154
+ images["mask"], images_file_paths["mask"] = self._load_input_image(case[1])
155
+
156
+ images["region"] = self.region
157
+
158
+ # Predict and generate output
159
+ out = self.predict(input_dict=images)
160
+
161
+ # Write resulting segmentation to output location
162
+ out_path = self.output_path / images_file_paths["image"].name
163
+ if not self.output_path.exists():
164
+ self.output_path.mkdir(parents=True, exist_ok=True)
165
+
166
+ SimpleITK.WriteImage(out, str(out_path), True)
167
+
168
+ # Write segmentation file path to result.json for this case
169
+ return {
170
+ "outputs": [dict(type="metaio_image", filename=str(out_path))],
171
+ "inputs": [
172
+ dict(type="metaio_image", filename=str(fn))
173
+ for fn in images_file_paths.values()
174
+ ] + [dict(type="String", filename=str(self.region_path))],
175
+ "error_messages": [],
176
+ }
177
+
178
+ def _load_input_image(self, image) -> Tuple[SimpleITK.Image, Path]:
179
+ input_image_file_path = image["path"]
180
+ input_image_file_loader = self._file_loader
181
+
182
+ if not isinstance(input_image_file_loader, ImageLoader):
183
+ raise RuntimeError("The used FileLoader was not of subclass ImageLoader")
184
+
185
+ # Load the image
186
+ input_image = input_image_file_loader.load_image(input_image_file_path)
187
+
188
+ # Check that it is the expected image
189
+ if input_image_file_loader.hash_image(input_image) != image["hash"]:
190
+ raise RuntimeError("Image hashes do not match")
191
+ return input_image, input_image_file_path
192
+
193
+ @abstractmethod
194
+ def predict(self, *, input_dict: Dict[str, SimpleITK.Image]) -> SimpleITK.Image:
195
+ pass
196
+
197
+ def save(self):
198
+ with open(str(self.output_file), "w") as f:
199
+ json.dump(self._case_results, f)
200
+
201
+ def process(self):
202
+ self.load()
203
+ self.validate()
204
+ self.process_cases()
205
+ self.save()
docker_task_1/build.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
3
+
4
+ docker build -t synthrad_algorithm_mri "$SCRIPTPATH"
docker_task_1/dynamic-network-architectures/.gitignore ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ env/
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # PyInstaller
28
+ # Usually these files are written by a python script from a template
29
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .coverage.*
42
+ .cache
43
+ nosetests.xml
44
+ coverage.xml
45
+ *,cover
46
+ .hypothesis/
47
+
48
+ # Translations
49
+ *.mo
50
+ *.pot
51
+
52
+ # Django stuff:
53
+ *.log
54
+ local_settings.py
55
+
56
+ # Flask stuff:
57
+ instance/
58
+ .webassets-cache
59
+
60
+ # Scrapy stuff:
61
+ .scrapy
62
+
63
+ # Sphinx documentation
64
+ docs/_build/
65
+
66
+ # PyBuilder
67
+ target/
68
+
69
+ # IPython Notebook
70
+ .ipynb_checkpoints
71
+
72
+ # pyenv
73
+ .python-version
74
+
75
+ # celery beat schedule file
76
+ celerybeat-schedule
77
+
78
+ # dotenv
79
+ .env
80
+
81
+ # virtualenv
82
+ venv/
83
+ ENV/
84
+
85
+ # Spyder project settings
86
+ .spyderproject
87
+
88
+ # Rope project settings
89
+ .ropeproject
90
+
91
+ *.memmap
92
+ *.zip
93
+ *.npz
94
+ *.npy
95
+ *.jpg
96
+ *.jpeg
97
+ .idea
98
+ *.txt
99
+ .idea/*
100
+ *.nii.gz
101
+ *.nii
102
+ *.tif
103
+ *.bmp
104
+ *.pkl
105
+ *.xml
106
+ *.pkl
107
+ *.pdf
108
+ *.jpg
109
+ *.jpeg
110
+
111
+ *.model
112
+
113
+ cifar_lightning/mlruns*
docker_task_1/dynamic-network-architectures/LICENCE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2022] [Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
docker_task_1/dynamic-network-architectures/README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # dynamic-network-architectures_translation
2
+ This repository adapts the dynamic-network-architectures for image-to-image translation tasks. It is based on the original repository found at [MIC-DKFZ/dynamic-network-architectures](https://github.com/MIC-DKFZ/dynamic-network-architectures).
3
+
4
+ ## Changes Made
5
+ - **UNet Decoder Improvements**: Added upsampling + convolution in the UNet decoder instead of transposed convolution to help prevent checkerboard artifacts, especially when using perceptual loss. cf [this article](https://distill.pub/2016/deconv-checkerboard/).
6
+ - `Upsample_Trilinear`
7
+ - `Upsample_Nearest`
8
+
9
+ ## Updates
10
+ - Added an argument to control the choice of UNet decoder : decoder_type ["standard", "trilinear", "nearest"]
11
+
12
+
13
+ ## TODO
14
+ - Test if `tanh` is necessary after the last convolution in decoder (constrain to [-1 ; 1])
docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/PKG-INFO ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: dynamic_network_architectures
3
+ Version: 0.3.1
4
+ Summary: none
5
+ Author: Fabian Isensee
6
+ Author-email: f.isensee@dkfz.de
7
+ License: private
8
+ License-File: LICENCE
9
+ Requires-Dist: torch>=1.6.0a
10
+ Requires-Dist: numpy
11
+ Dynamic: author
12
+ Dynamic: author-email
13
+ Dynamic: license
14
+ Dynamic: license-file
15
+ Dynamic: requires-dist
16
+ Dynamic: summary
docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/SOURCES.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LICENCE
2
+ README.md
3
+ setup.py
4
+ dynamic_network_architectures/__init__.py
5
+ dynamic_network_architectures.egg-info/PKG-INFO
6
+ dynamic_network_architectures.egg-info/SOURCES.txt
7
+ dynamic_network_architectures.egg-info/dependency_links.txt
8
+ dynamic_network_architectures.egg-info/not-zip-safe
9
+ dynamic_network_architectures.egg-info/requires.txt
10
+ dynamic_network_architectures.egg-info/top_level.txt
11
+ dynamic_network_architectures/architectures/__init__.py
12
+ dynamic_network_architectures/architectures/resnet.py
13
+ dynamic_network_architectures/architectures/unet.py
14
+ dynamic_network_architectures/architectures/vgg.py
15
+ dynamic_network_architectures/building_blocks/__init__.py
16
+ dynamic_network_architectures/building_blocks/helper.py
17
+ dynamic_network_architectures/building_blocks/plain_conv_encoder.py
18
+ dynamic_network_architectures/building_blocks/regularization.py
19
+ dynamic_network_architectures/building_blocks/residual.py
20
+ dynamic_network_architectures/building_blocks/residual_encoders.py
21
+ dynamic_network_architectures/building_blocks/simple_conv_blocks.py
22
+ dynamic_network_architectures/building_blocks/unet_decoder.py
23
+ dynamic_network_architectures/building_blocks/unet_decoder_upsample_nearest.py
24
+ dynamic_network_architectures/building_blocks/unet_decoder_upsample_trilinear.py
25
+ dynamic_network_architectures/building_blocks/unet_residual_decoder.py
26
+ dynamic_network_architectures/initialization/__init__.py
27
+ dynamic_network_architectures/initialization/weight_init.py
docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/not-zip-safe ADDED
@@ -0,0 +1 @@
 
 
1
+
docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/requires.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch>=1.6.0a
2
+ numpy
docker_task_1/dynamic-network-architectures/dynamic_network_architectures.egg-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ dynamic_network_architectures
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/__init__.py ADDED
File without changes
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (199 Bytes). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (218 Bytes). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__init__.py ADDED
File without changes
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (213 Bytes). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (232 Bytes). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__pycache__/unet.cpython-310.pyc ADDED
Binary file (7.62 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/__pycache__/unet.cpython-312.pyc ADDED
Binary file (13.2 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/resnet.py ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from dynamic_network_architectures.building_blocks.residual_encoders import ResidualEncoder, BottleneckD, BasicBlockD
3
+ from dynamic_network_architectures.building_blocks.helper import get_matching_pool_op, get_default_network_config
4
+ from dynamic_network_architectures.building_blocks.simple_conv_blocks import ConvDropoutNormReLU
5
+ from torch import nn
6
+
7
+ _ResNet_CONFIGS = {
8
+ '18': {'features_per_stage': (64, 128, 256, 512), 'n_blocks_per_stage': (2, 2, 2, 2), 'strides': (1, 2, 2, 2),
9
+ 'block': BasicBlockD, 'bottleneck_channels': None, 'disable_default_stem': True, 'stem_channels': None},
10
+ '34': {'features_per_stage': (64, 128, 256, 512), 'n_blocks_per_stage': (3, 4, 6, 3), 'strides': (1, 2, 2, 2),
11
+ 'block': BasicBlockD, 'bottleneck_channels': None, 'disable_default_stem': True, 'stem_channels': None},
12
+ '50': {'features_per_stage': (64, 128, 256, 512), 'n_blocks_per_stage': (4, 6, 10, 5), 'strides': (1, 2, 2, 2),
13
+ 'block': BasicBlockD, 'bottleneck_channels': None, 'disable_default_stem': True, 'stem_channels': None},
14
+ '152': {'features_per_stage': (64, 128, 256, 512), 'n_blocks_per_stage': (4, 13, 55, 4), 'strides': (1, 2, 2, 2),
15
+ 'block': BasicBlockD, 'bottleneck_channels': None, 'disable_default_stem': True, 'stem_channels': None},
16
+ '50_bn': {'features_per_stage': (256, 512, 1024, 2048), 'n_blocks_per_stage': (3, 4, 6, 3), 'strides': (1, 2, 2, 2),
17
+ 'block': BottleneckD, 'bottleneck_channels': (64, 128, 256, 512), 'disable_default_stem': True,
18
+ 'stem_channels': 64},
19
+ '152_bn': {'features_per_stage': (256, 512, 1024, 2048), 'n_blocks_per_stage': (3, 8, 36, 3),
20
+ 'strides': (1, 2, 2, 2),
21
+ 'block': BottleneckD, 'bottleneck_channels': (64, 128, 256, 512), 'disable_default_stem': True,
22
+ 'stem_channels': 64},
23
+ '18_cifar': {'features_per_stage': (64, 128, 256, 512), 'n_blocks_per_stage': (2, 2, 2, 2), 'strides': (1, 2, 2, 2),
24
+ 'block': BasicBlockD, 'bottleneck_channels': None, 'disable_default_stem': False,
25
+ 'stem_channels': None},
26
+ '34_cifar': {'features_per_stage': (64, 128, 256, 512), 'n_blocks_per_stage': (3, 4, 6, 3), 'strides': (1, 2, 2, 2),
27
+ 'block': BasicBlockD, 'bottleneck_channels': None, 'disable_default_stem': False,
28
+ 'stem_channels': None},
29
+ '50_cifar': {'features_per_stage': (64, 128, 256, 512), 'n_blocks_per_stage': (4, 6, 10, 5),
30
+ 'strides': (1, 2, 2, 2),
31
+ 'block': BasicBlockD, 'bottleneck_channels': None, 'disable_default_stem': False,
32
+ 'stem_channels': None},
33
+ '152_cifar': {'features_per_stage': (64, 128, 256, 512), 'n_blocks_per_stage': (4, 13, 55, 4),
34
+ 'strides': (1, 2, 2, 2),
35
+ 'block': BasicBlockD, 'bottleneck_channels': None, 'disable_default_stem': False,
36
+ 'stem_channels': None},
37
+ '50_cifar_bn': {'features_per_stage': (256, 512, 1024, 2048), 'n_blocks_per_stage': (3, 4, 6, 3),
38
+ 'strides': (1, 2, 2, 2),
39
+ 'block': BottleneckD, 'bottleneck_channels': (64, 128, 256, 512), 'disable_default_stem': False,
40
+ 'stem_channels': 64},
41
+ '152_cifar_bn': {'features_per_stage': (256, 512, 1024, 2048), 'n_blocks_per_stage': (3, 8, 36, 3),
42
+ 'strides': (1, 2, 2, 2),
43
+ 'block': BottleneckD, 'bottleneck_channels': (64, 128, 256, 512), 'disable_default_stem': False,
44
+ 'stem_channels': 64},
45
+ }
46
+
47
+
48
+ class ResNetD(nn.Module):
49
+ def __init__(self, n_classes: int, n_input_channel: int = 3, config='18', input_dimension=2,
50
+ final_layer_dropout=0.0, stochastic_depth_p=0.0, squeeze_excitation=False,
51
+ squeeze_excitation_rd_ratio=1./16):
52
+ """
53
+ Implements ResNetD (https://arxiv.org/pdf/1812.01187.pdf).
54
+ Args:
55
+ n_classes: Number of classes
56
+ n_input_channel: Number of input channels (e.g. 3 for RGB)
57
+ config: Configuration of the ResNet
58
+ input_dimension: Number of dimensions of the data (1, 2 or 3)
59
+ final_layer_dropout: Probability of dropout before the final classifier
60
+ stochastic_depth_p: Stochastic Depth probability
61
+ squeeze_excitation: Whether Squeeze and Excitation should be applied
62
+ squeeze_excitation_rd_ratio: Squeeze and Excitation Reduction Ratio
63
+ Returns:
64
+ ResNet Model
65
+ """
66
+ super().__init__()
67
+ self.input_channels = n_input_channel
68
+ self.cfg = _ResNet_CONFIGS[config]
69
+ self.ops = get_default_network_config(dimension=input_dimension)
70
+ self.final_layer_dropout_p = final_layer_dropout
71
+
72
+ if self.cfg['disable_default_stem']:
73
+ stem_features = self.cfg['stem_channels'] if self.cfg['stem_channels'] is not None else \
74
+ self.cfg['features_per_stage'][0]
75
+ self.stem = self._build_imagenet_stem_D(stem_features)
76
+ encoder_input_features = stem_features
77
+ else:
78
+ encoder_input_features = n_input_channel
79
+ self.stem = None
80
+
81
+ self.encoder = ResidualEncoder(encoder_input_features, n_stages=len(self.cfg['features_per_stage']),
82
+ features_per_stage=self.cfg['features_per_stage'], conv_op=self.ops['conv_op'],
83
+ kernel_sizes=3, strides=self.cfg['strides'],
84
+ n_blocks_per_stage=self.cfg['n_blocks_per_stage'], conv_bias=False,
85
+ norm_op=self.ops['norm_op'], norm_op_kwargs=None, dropout_op=None,
86
+ dropout_op_kwargs=None, nonlin=nn.ReLU,
87
+ nonlin_kwargs={'inplace': True}, block=self.cfg['block'],
88
+ bottleneck_channels=self.cfg['bottleneck_channels'], return_skips=False,
89
+ disable_default_stem=self.cfg['disable_default_stem'],
90
+ stem_channels=self.cfg['stem_channels'],
91
+ stochastic_depth_p=stochastic_depth_p,
92
+ squeeze_excitation=squeeze_excitation,
93
+ squeeze_excitation_reduction_ratio=squeeze_excitation_rd_ratio)
94
+
95
+ self.gap = get_matching_pool_op(conv_op=self.ops['conv_op'], adaptive=True, pool_type='avg')(1)
96
+ self.classifier = nn.Linear(self.cfg['features_per_stage'][-1], n_classes, True)
97
+ self.final_layer_dropout = self.ops['dropout_op'](p=self.final_layer_dropout_p)
98
+
99
+ def forward(self, x):
100
+ if self.stem is not None:
101
+ x = self.stem(x)
102
+ x = self.encoder(x)
103
+ x = self.gap(x)
104
+ x = self.final_layer_dropout(x).squeeze()
105
+
106
+ return self.classifier(x)
107
+
108
+ def _build_imagenet_stem_D(self, stem_features):
109
+ """
110
+ https://arxiv.org/pdf/1812.01187.pdf
111
+
112
+ use 3 3x3(x3) convs instead of one 7x7. Stride is located in first conv.
113
+
114
+ Fig2 b) describes this
115
+ :return:
116
+ """
117
+ c1 = ConvDropoutNormReLU(self.ops['conv_op'], self.input_channels, stem_features, 3, 2, False,
118
+ self.ops['norm_op'], None, None, None, nn.ReLU, {'inplace': True})
119
+ c2 = ConvDropoutNormReLU(self.ops['conv_op'], stem_features, stem_features, 3, 1, False,
120
+ self.ops['norm_op'], None, None, None, nn.ReLU, {'inplace': True})
121
+ c3 = ConvDropoutNormReLU(self.ops['conv_op'], stem_features, stem_features, 3, 1, False,
122
+ self.ops['norm_op'], None, None, None, nn.ReLU, {'inplace': True})
123
+ pl = get_matching_pool_op(conv_op=self.ops['conv_op'], adaptive=False, pool_type='max')(2)
124
+ stem = nn.Sequential(c1, c2, c3, pl)
125
+ return stem
126
+
127
+
128
+ class ResNet18_CIFAR(ResNetD):
129
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
130
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
131
+ squeeze_excitation_rd_ratio: float = 1./16):
132
+ super().__init__(n_classes, n_input_channels, config='18_cifar', input_dimension=input_dimension,
133
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
134
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
135
+
136
+ class ResNet34_CIFAR(ResNetD):
137
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
138
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
139
+ squeeze_excitation_rd_ratio: float = 1./16):
140
+ super().__init__(n_classes, n_input_channels, config='34_cifar', input_dimension=input_dimension,
141
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
142
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
143
+
144
+ class ResNet50_CIFAR(ResNetD):
145
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
146
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
147
+ squeeze_excitation_rd_ratio: float = 1./16):
148
+ super().__init__(n_classes, n_input_channels, config='50_cifar', input_dimension=input_dimension,
149
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
150
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
151
+
152
+ class ResNet152_CIFAR(ResNetD):
153
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
154
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
155
+ squeeze_excitation_rd_ratio: float = 1./16):
156
+ super().__init__(n_classes, n_input_channels, config='152_cifar', input_dimension=input_dimension,
157
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
158
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
159
+
160
+ class ResNet50bn_CIFAR(ResNetD):
161
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
162
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
163
+ squeeze_excitation_rd_ratio: float = 1./16):
164
+ super().__init__(n_classes, n_input_channels, config='50_cifar_bn', input_dimension=input_dimension,
165
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
166
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
167
+
168
+ class ResNet152bn_CIFAR(ResNetD):
169
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
170
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
171
+ squeeze_excitation_rd_ratio: float = 1./16):
172
+ super().__init__(n_classes, n_input_channels, config='152_cifar_bn', input_dimension=input_dimension,
173
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
174
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
175
+
176
+ class ResNet18(ResNetD):
177
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
178
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
179
+ squeeze_excitation_rd_ratio: float = 1./16):
180
+ super().__init__(n_classes, n_input_channels, config='18', input_dimension=input_dimension,
181
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
182
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
183
+
184
+ class ResNet34(ResNetD):
185
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
186
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
187
+ squeeze_excitation_rd_ratio: float = 1./16):
188
+ super().__init__(n_classes, n_input_channels, config='34', input_dimension=input_dimension,
189
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
190
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
191
+
192
+ class ResNet50(ResNetD):
193
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
194
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
195
+ squeeze_excitation_rd_ratio: float = 1./16):
196
+ super().__init__(n_classes, n_input_channels, config='50', input_dimension=input_dimension,
197
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
198
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
199
+
200
+ class ResNet152(ResNetD):
201
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
202
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
203
+ squeeze_excitation_rd_ratio: float = 1./16):
204
+ super().__init__(n_classes, n_input_channels, config='152', input_dimension=input_dimension,
205
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
206
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
207
+
208
+ class ResNet50bn(ResNetD):
209
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
210
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
211
+ squeeze_excitation_rd_ratio: float = 1./16):
212
+ super().__init__(n_classes, n_input_channels, config='50_bn', input_dimension=input_dimension,
213
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
214
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
215
+
216
+ class ResNet152bn(ResNetD):
217
+ def __init__(self, n_classes: int, n_input_channels: int = 3, input_dimension: int = 2,
218
+ final_layer_dropout: float = 0.0, stochastic_depth_p: float = 0.0, squeeze_excitation: bool = False,
219
+ squeeze_excitation_rd_ratio: float = 1./16):
220
+ super().__init__(n_classes, n_input_channels, config='152_bn', input_dimension=input_dimension,
221
+ final_layer_dropout=final_layer_dropout, stochastic_depth_p=stochastic_depth_p,
222
+ squeeze_excitation=squeeze_excitation, squeeze_excitation_rd_ratio=squeeze_excitation_rd_ratio)
223
+
224
+
225
+ if __name__ == '__main__':
226
+ data = torch.rand((1, 3, 224, 224))
227
+
228
+ model = ResNet50bn(10, 3)
229
+ import hiddenlayer as hl
230
+
231
+ g = hl.build_graph(model, data,
232
+ transforms=None)
233
+ g.save("network_architecture.pdf")
234
+ del g
235
+
236
+ #print(model.compute_conv_feature_map_size((32, 32)))
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/unet.py ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union, Type, List, Tuple
2
+
3
+ import torch
4
+ from dynamic_network_architectures.building_blocks.helper import convert_conv_op_to_dim
5
+ from dynamic_network_architectures.building_blocks.plain_conv_encoder import PlainConvEncoder
6
+ from dynamic_network_architectures.building_blocks.residual import BasicBlockD, BottleneckD
7
+ from dynamic_network_architectures.building_blocks.residual_encoders import ResidualEncoder
8
+ from dynamic_network_architectures.building_blocks.unet_decoder import UNetDecoder
9
+ from dynamic_network_architectures.building_blocks.unet_residual_decoder import UNetResDecoder
10
+ from dynamic_network_architectures.initialization.weight_init import InitWeights_He
11
+ from dynamic_network_architectures.initialization.weight_init import init_last_bn_before_add_to_0
12
+
13
+ from dynamic_network_architectures.building_blocks.unet_decoder_upsample_trilinear import UNetDecoder_Upsample_Trilinear
14
+ from dynamic_network_architectures.building_blocks.unet_decoder_upsample_nearest import UNetDecoder_Upsample_Nearest
15
+
16
+
17
+ from torch import nn
18
+ from torch.nn.modules.conv import _ConvNd
19
+ from torch.nn.modules.dropout import _DropoutNd
20
+
21
+
22
+ class PlainConvUNet(nn.Module):
23
+ def __init__(self,
24
+ input_channels: int,
25
+ n_stages: int,
26
+ features_per_stage: Union[int, List[int], Tuple[int, ...]],
27
+ conv_op: Type[_ConvNd],
28
+ kernel_sizes: Union[int, List[int], Tuple[int, ...]],
29
+ strides: Union[int, List[int], Tuple[int, ...]],
30
+ n_conv_per_stage: Union[int, List[int], Tuple[int, ...]],
31
+ num_classes: int,
32
+ n_conv_per_stage_decoder: Union[int, Tuple[int, ...], List[int]],
33
+ conv_bias: bool = False,
34
+ norm_op: Union[None, Type[nn.Module]] = None,
35
+ norm_op_kwargs: dict = None,
36
+ dropout_op: Union[None, Type[_DropoutNd]] = None,
37
+ dropout_op_kwargs: dict = None,
38
+ nonlin: Union[None, Type[torch.nn.Module]] = None,
39
+ nonlin_kwargs: dict = None,
40
+ deep_supervision: bool = False,
41
+ nonlin_first: bool = False,
42
+ decoder_type: str="standard"
43
+ ):
44
+ """
45
+ nonlin_first: if True you get conv -> nonlin -> norm. Else it's conv -> norm -> nonlin
46
+ """
47
+ super().__init__()
48
+ if isinstance(n_conv_per_stage, int):
49
+ n_conv_per_stage = [n_conv_per_stage] * n_stages
50
+ if isinstance(n_conv_per_stage_decoder, int):
51
+ n_conv_per_stage_decoder = [n_conv_per_stage_decoder] * (n_stages - 1)
52
+ assert len(n_conv_per_stage) == n_stages, "n_conv_per_stage must have as many entries as we have " \
53
+ f"resolution stages. here: {n_stages}. " \
54
+ f"n_conv_per_stage: {n_conv_per_stage}"
55
+ assert len(n_conv_per_stage_decoder) == (n_stages - 1), "n_conv_per_stage_decoder must have one less entries " \
56
+ f"as we have resolution stages. here: {n_stages} " \
57
+ f"stages, so it should have {n_stages - 1} entries. " \
58
+ f"n_conv_per_stage_decoder: {n_conv_per_stage_decoder}"
59
+ self.encoder = PlainConvEncoder(input_channels, n_stages, features_per_stage, conv_op, kernel_sizes, strides,
60
+ n_conv_per_stage, conv_bias, norm_op, norm_op_kwargs, dropout_op,
61
+ dropout_op_kwargs, nonlin, nonlin_kwargs, return_skips=True,
62
+ nonlin_first=nonlin_first)
63
+ if decoder_type == "standard":
64
+ self.decoder = UNetDecoder(self.encoder, num_classes, n_conv_per_stage_decoder, deep_supervision, nonlin_first=nonlin_first)
65
+ elif decoder_type == "trilinear":
66
+ self.decoder = UNetDecoder_Upsample_Trilinear(self.encoder, num_classes, n_conv_per_stage_decoder, deep_supervision, nonlin_first=nonlin_first)
67
+ elif decoder_type == "nearest":
68
+ self.decoder = UNetDecoder_Upsample_Nearest(self.encoder, num_classes, n_conv_per_stage_decoder, deep_supervision, nonlin_first=nonlin_first)
69
+ else:
70
+ raise ValueError(f"Unsupported decoder type: {decoder_type}. Choose from 'standard', 'trilinear', or 'nearest'.")
71
+
72
+ def forward(self, x):
73
+ skips = self.encoder(x)
74
+ output = self.decoder(skips)
75
+ # output = torch.tanh(output) # added tanh for translation. TODO: perform ablation study + add a parameter to control this
76
+ return output
77
+
78
+ def compute_conv_feature_map_size(self, input_size):
79
+ assert len(input_size) == convert_conv_op_to_dim(self.encoder.conv_op), "just give the image size without color/feature channels or " \
80
+ "batch channel. Do not give input_size=(b, c, x, y(, z)). " \
81
+ "Give input_size=(x, y(, z))!"
82
+ return self.encoder.compute_conv_feature_map_size(input_size) + self.decoder.compute_conv_feature_map_size(input_size)
83
+
84
+ @staticmethod
85
+ def initialize(module):
86
+ InitWeights_He(1e-2)(module)
87
+
88
+
89
+ class ResidualEncoderUNet(nn.Module):
90
+ def __init__(self,
91
+ input_channels: int,
92
+ n_stages: int,
93
+ features_per_stage: Union[int, List[int], Tuple[int, ...]],
94
+ conv_op: Type[_ConvNd],
95
+ kernel_sizes: Union[int, List[int], Tuple[int, ...]],
96
+ strides: Union[int, List[int], Tuple[int, ...]],
97
+ n_blocks_per_stage: Union[int, List[int], Tuple[int, ...]],
98
+ num_classes: int,
99
+ n_conv_per_stage_decoder: Union[int, Tuple[int, ...], List[int]],
100
+ conv_bias: bool = False,
101
+ norm_op: Union[None, Type[nn.Module]] = None,
102
+ norm_op_kwargs: dict = None,
103
+ dropout_op: Union[None, Type[_DropoutNd]] = None,
104
+ dropout_op_kwargs: dict = None,
105
+ nonlin: Union[None, Type[torch.nn.Module]] = None,
106
+ nonlin_kwargs: dict = None,
107
+ deep_supervision: bool = False,
108
+ block: Union[Type[BasicBlockD], Type[BottleneckD]] = BasicBlockD,
109
+ bottleneck_channels: Union[int, List[int], Tuple[int, ...]] = None,
110
+ stem_channels: int = None
111
+ ):
112
+ super().__init__()
113
+ if isinstance(n_blocks_per_stage, int):
114
+ n_blocks_per_stage = [n_blocks_per_stage] * n_stages
115
+ if isinstance(n_conv_per_stage_decoder, int):
116
+ n_conv_per_stage_decoder = [n_conv_per_stage_decoder] * (n_stages - 1)
117
+ assert len(n_blocks_per_stage) == n_stages, "n_blocks_per_stage must have as many entries as we have " \
118
+ f"resolution stages. here: {n_stages}. " \
119
+ f"n_blocks_per_stage: {n_blocks_per_stage}"
120
+ assert len(n_conv_per_stage_decoder) == (n_stages - 1), "n_conv_per_stage_decoder must have one less entries " \
121
+ f"as we have resolution stages. here: {n_stages} " \
122
+ f"stages, so it should have {n_stages - 1} entries. " \
123
+ f"n_conv_per_stage_decoder: {n_conv_per_stage_decoder}"
124
+ self.encoder = ResidualEncoder(input_channels, n_stages, features_per_stage, conv_op, kernel_sizes, strides,
125
+ n_blocks_per_stage, conv_bias, norm_op, norm_op_kwargs, dropout_op,
126
+ dropout_op_kwargs, nonlin, nonlin_kwargs, block, bottleneck_channels,
127
+ return_skips=True, disable_default_stem=False, stem_channels=stem_channels)
128
+ self.decoder = UNetDecoder(self.encoder, num_classes, n_conv_per_stage_decoder, deep_supervision)
129
+
130
+ def forward(self, x):
131
+ skips = self.encoder(x)
132
+ return self.decoder(skips)
133
+
134
+ def compute_conv_feature_map_size(self, input_size):
135
+ assert len(input_size) == convert_conv_op_to_dim(self.encoder.conv_op), "just give the image size without color/feature channels or " \
136
+ "batch channel. Do not give input_size=(b, c, x, y(, z)). " \
137
+ "Give input_size=(x, y(, z))!"
138
+ return self.encoder.compute_conv_feature_map_size(input_size) + self.decoder.compute_conv_feature_map_size(input_size)
139
+
140
+ @staticmethod
141
+ def initialize(module):
142
+ InitWeights_He(1e-2)(module)
143
+ init_last_bn_before_add_to_0(module)
144
+
145
+
146
+ class ResidualUNet(nn.Module):
147
+ def __init__(self,
148
+ input_channels: int,
149
+ n_stages: int,
150
+ features_per_stage: Union[int, List[int], Tuple[int, ...]],
151
+ conv_op: Type[_ConvNd],
152
+ kernel_sizes: Union[int, List[int], Tuple[int, ...]],
153
+ strides: Union[int, List[int], Tuple[int, ...]],
154
+ n_blocks_per_stage: Union[int, List[int], Tuple[int, ...]],
155
+ num_classes: int,
156
+ n_conv_per_stage_decoder: Union[int, Tuple[int, ...], List[int]],
157
+ conv_bias: bool = False,
158
+ norm_op: Union[None, Type[nn.Module]] = None,
159
+ norm_op_kwargs: dict = None,
160
+ dropout_op: Union[None, Type[_DropoutNd]] = None,
161
+ dropout_op_kwargs: dict = None,
162
+ nonlin: Union[None, Type[torch.nn.Module]] = None,
163
+ nonlin_kwargs: dict = None,
164
+ deep_supervision: bool = False,
165
+ block: Union[Type[BasicBlockD], Type[BottleneckD]] = BasicBlockD,
166
+ bottleneck_channels: Union[int, List[int], Tuple[int, ...]] = None,
167
+ stem_channels: int = None
168
+ ):
169
+ super().__init__()
170
+ if isinstance(n_blocks_per_stage, int):
171
+ n_blocks_per_stage = [n_blocks_per_stage] * n_stages
172
+ if isinstance(n_conv_per_stage_decoder, int):
173
+ n_conv_per_stage_decoder = [n_conv_per_stage_decoder] * (n_stages - 1)
174
+ assert len(n_blocks_per_stage) == n_stages, "n_blocks_per_stage must have as many entries as we have " \
175
+ f"resolution stages. here: {n_stages}. " \
176
+ f"n_blocks_per_stage: {n_blocks_per_stage}"
177
+ assert len(n_conv_per_stage_decoder) == (n_stages - 1), "n_conv_per_stage_decoder must have one less entries " \
178
+ f"as we have resolution stages. here: {n_stages} " \
179
+ f"stages, so it should have {n_stages - 1} entries. " \
180
+ f"n_conv_per_stage_decoder: {n_conv_per_stage_decoder}"
181
+ self.encoder = ResidualEncoder(input_channels, n_stages, features_per_stage, conv_op, kernel_sizes, strides,
182
+ n_blocks_per_stage, conv_bias, norm_op, norm_op_kwargs, dropout_op,
183
+ dropout_op_kwargs, nonlin, nonlin_kwargs, block, bottleneck_channels,
184
+ return_skips=True, disable_default_stem=False, stem_channels=stem_channels)
185
+ self.decoder = UNetResDecoder(self.encoder, num_classes, n_conv_per_stage_decoder, deep_supervision)
186
+
187
+ def forward(self, x):
188
+ skips = self.encoder(x)
189
+ return self.decoder(skips)
190
+
191
+ def compute_conv_feature_map_size(self, input_size):
192
+ assert len(input_size) == convert_conv_op_to_dim(self.encoder.conv_op), "just give the image size without color/feature channels or " \
193
+ "batch channel. Do not give input_size=(b, c, x, y(, z)). " \
194
+ "Give input_size=(x, y(, z))!"
195
+ return self.encoder.compute_conv_feature_map_size(input_size) + self.decoder.compute_conv_feature_map_size(input_size)
196
+
197
+ @staticmethod
198
+ def initialize(module):
199
+ InitWeights_He(1e-2)(module)
200
+ init_last_bn_before_add_to_0(module)
201
+
202
+
203
+ if __name__ == '__main__':
204
+ data = torch.rand((1, 4, 128, 128, 128))
205
+
206
+ model = PlainConvUNet(4, 6, (32, 64, 125, 256, 320, 320), nn.Conv3d, 3, (1, 2, 2, 2, 2, 2), (2, 2, 2, 2, 2, 2), 4,
207
+ (2, 2, 2, 2, 2), False, nn.BatchNorm3d, None, None, None, nn.ReLU, deep_supervision=True)
208
+
209
+ if False:
210
+ import hiddenlayer as hl
211
+
212
+ g = hl.build_graph(model, data,
213
+ transforms=None)
214
+ g.save("network_architecture.pdf")
215
+ del g
216
+
217
+ print(model.compute_conv_feature_map_size(data.shape[2:]))
218
+
219
+ data = torch.rand((1, 4, 512, 512))
220
+
221
+ model = PlainConvUNet(4, 8, (32, 64, 125, 256, 512, 512, 512, 512), nn.Conv2d, 3, (1, 2, 2, 2, 2, 2, 2, 2), (2, 2, 2, 2, 2, 2, 2, 2), 4,
222
+ (2, 2, 2, 2, 2, 2, 2), False, nn.BatchNorm2d, None, None, None, nn.ReLU, deep_supervision=True)
223
+
224
+ if False:
225
+ import hiddenlayer as hl
226
+
227
+ g = hl.build_graph(model, data,
228
+ transforms=None)
229
+ g.save("network_architecture.pdf")
230
+ del g
231
+
232
+ print(model.compute_conv_feature_map_size(data.shape[2:]))
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/architectures/vgg.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+
4
+ from dynamic_network_architectures.building_blocks.plain_conv_encoder import PlainConvEncoder
5
+ from dynamic_network_architectures.building_blocks.helper import get_matching_pool_op, get_default_network_config
6
+
7
+ _VGG_CONFIGS = {
8
+ '16': {'features_per_stage': (64, 128, 256, 512, 512, 512), 'n_conv_per_stage': (2, 2, 2, 3, 3, 3),
9
+ 'strides': (1, 2, 2, 2, 2, 2)},
10
+ '19': {'features_per_stage': (64, 128, 256, 512, 512, 512), 'n_conv_per_stage': (2, 2, 3, 3, 4, 4),
11
+ 'strides': (1, 2, 2, 2, 2, 2)},
12
+ '16_cifar': {'features_per_stage': (64, 128, 256, 512), 'n_conv_per_stage': (2, 3, 5, 5), 'strides': (1, 2, 2, 2)},
13
+ '19_cifar': {'features_per_stage': (64, 128, 256, 512), 'n_conv_per_stage': (3, 4, 5, 6), 'strides': (1, 2, 2, 2)},
14
+ }
15
+
16
+ _VGG_OPS = {
17
+ 1: {'conv_op': nn.Conv1d, 'norm_op': nn.BatchNorm1d},
18
+ 2: {'conv_op': nn.Conv2d, 'norm_op': nn.BatchNorm2d},
19
+ 3: {'conv_op': nn.Conv3d, 'norm_op': nn.BatchNorm3d},
20
+ }
21
+
22
+
23
+ class VGG(nn.Module):
24
+ def __init__(self, n_classes: int, n_input_channel: int = 3, config='16', input_dimension=2):
25
+ """
26
+ This is not 1:1 VGG because it does not have the bloated fully connected layers at the end. Since these were
27
+ counted towards the XX layers as well, we increase the number of convolutional layers so that we have the
28
+ desired number of conv layers in total
29
+
30
+ We also use batchnorm
31
+ """
32
+ super().__init__()
33
+ cfg = _VGG_CONFIGS[config]
34
+ ops = get_default_network_config(dimension=input_dimension)
35
+ self.encoder = PlainConvEncoder(
36
+ n_input_channel, n_stages=len(cfg['features_per_stage']), features_per_stage=cfg['features_per_stage'],
37
+ conv_op=ops['conv_op'],
38
+ kernel_sizes=3, strides=cfg['strides'], n_conv_per_stage=cfg['n_conv_per_stage'], conv_bias=False,
39
+ norm_op=ops['norm_op'], norm_op_kwargs=None, dropout_op=None, dropout_op_kwargs=None, nonlin=nn.ReLU,
40
+ nonlin_kwargs={'inplace': True}, return_skips=False
41
+ )
42
+ self.gap = get_matching_pool_op(conv_op=ops['conv_op'], adaptive=True, pool_type='avg')(1)
43
+ self.classifier = nn.Linear(cfg['features_per_stage'][-1], n_classes, True)
44
+
45
+ def forward(self, x):
46
+ x = self.encoder(x)
47
+ x = self.gap(x).squeeze()
48
+ return self.classifier(x)
49
+
50
+ def compute_conv_feature_map_size(self, input_size):
51
+ return self.encoder.compute_conv_feature_map_size(input_size)
52
+
53
+
54
+ class VGG16(VGG):
55
+ def __init__(self, n_classes: int, n_input_channel: int = 3, input_dimension: int = 2):
56
+ super().__init__(n_classes, n_input_channel, config='16', input_dimension=input_dimension)
57
+
58
+
59
+ class VGG19(VGG):
60
+ def __init__(self, n_classes: int, n_input_channel: int = 3, input_dimension: int = 2):
61
+ super().__init__(n_classes, n_input_channel, config='19', input_dimension=input_dimension)
62
+
63
+
64
+ class VGG16_cifar(VGG):
65
+ def __init__(self, n_classes: int, n_input_channel: int = 3, input_dimension: int = 2):
66
+ super().__init__(n_classes, n_input_channel, config='16_cifar', input_dimension=input_dimension)
67
+
68
+
69
+ class VGG19_cifar(VGG):
70
+ def __init__(self, n_classes: int, n_input_channel: int = 3, input_dimension: int = 2):
71
+ super().__init__(n_classes, n_input_channel, config='19_cifar', input_dimension=input_dimension)
72
+
73
+
74
+ if __name__ == '__main__':
75
+ data = torch.rand((1, 3, 32, 32))
76
+
77
+ model = VGG19_cifar(10, 3)
78
+ import hiddenlayer as hl
79
+
80
+ g = hl.build_graph(model, data,
81
+ transforms=None)
82
+ g.save("network_architecture.pdf")
83
+ del g
84
+
85
+ print(model.compute_conv_feature_map_size((32, 32)))
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__init__.py ADDED
File without changes
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (215 Bytes). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (234 Bytes). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/helper.cpython-310.pyc ADDED
Binary file (5.87 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/helper.cpython-312.pyc ADDED
Binary file (8.63 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/plain_conv_encoder.cpython-310.pyc ADDED
Binary file (4.16 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/plain_conv_encoder.cpython-312.pyc ADDED
Binary file (6.19 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/regularization.cpython-310.pyc ADDED
Binary file (4.33 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/regularization.cpython-312.pyc ADDED
Binary file (5.64 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/residual.cpython-310.pyc ADDED
Binary file (14.1 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/residual.cpython-312.pyc ADDED
Binary file (20.2 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/residual_encoders.cpython-310.pyc ADDED
Binary file (6.34 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/residual_encoders.cpython-312.pyc ADDED
Binary file (8.72 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/simple_conv_blocks.cpython-310.pyc ADDED
Binary file (5.79 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/simple_conv_blocks.cpython-312.pyc ADDED
Binary file (8.15 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/unet_decoder.cpython-310.pyc ADDED
Binary file (5.01 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/unet_decoder.cpython-312.pyc ADDED
Binary file (7.88 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/unet_decoder_upsample_nearest.cpython-310.pyc ADDED
Binary file (5.81 kB). View file
 
docker_task_1/dynamic-network-architectures/dynamic_network_architectures/building_blocks/__pycache__/unet_decoder_upsample_nearest.cpython-312.pyc ADDED
Binary file (9.22 kB). View file