VBoussot commited on
Commit
04f9b85
·
verified ·
1 Parent(s): 3afa33b

Fix model-intrinsic params in the model (input channels / class count / network architecture) instead of exposing them in the config

Browse files
Files changed (2) hide show
  1. body/Model.py +7 -5
  2. body/Prediction.yml +0 -2
body/Model.py CHANGED
@@ -11,6 +11,10 @@ def _replace_unpicklable_identities(module: nn.Module) -> None:
11
  child.nonlin2 = nn.Identity()
12
 
13
  class ResEnc(network.Network):
 
 
 
 
14
  def __init__(
15
  self,
16
  optimizer: network.OptimizerLoader = network.OptimizerLoader(),
@@ -18,25 +22,23 @@ class ResEnc(network.Network):
18
  "default:ReduceLROnPlateau": network.LRSchedulersLoader(0)
19
  },
20
  outputs_criterions: dict[str, network.TargetCriterionsLoader] = {"default": network.TargetCriterionsLoader()},
21
- in_channels: int = 5,
22
- nb_class: int = 132,
23
  ) -> None:
24
  super().__init__(
25
- in_channels=in_channels,
26
  optimizer=optimizer,
27
  schedulers=schedulers,
28
  outputs_criterions=outputs_criterions,
29
  dim=2,
30
  )
31
  self.add_module("DecoderOutputs", ResidualEncoderUNet(
32
- input_channels=in_channels,
33
  n_stages=6,
34
  features_per_stage=(24, 48, 96, 192, 256, 256),
35
  conv_op=nn.Conv2d,
36
  kernel_sizes=3,
37
  strides=(1, 2, 2, 2, 2, 2),
38
  n_blocks_per_stage=(1, 2, 2, 3, 3, 3),
39
- num_classes=nb_class,
40
  n_conv_per_stage_decoder=(1, 1, 1, 1, 1),
41
  conv_bias=True,
42
  norm_op=nn.InstanceNorm2d,
 
11
  child.nonlin2 = nn.Identity()
12
 
13
  class ResEnc(network.Network):
14
+ # Intrinsic to the pretrained weights (5-channel 2.5D input, 12 body structures), not tunables — fixed here.
15
+ IN_CHANNELS = 5
16
+ NUM_CLASSES = 12
17
+
18
  def __init__(
19
  self,
20
  optimizer: network.OptimizerLoader = network.OptimizerLoader(),
 
22
  "default:ReduceLROnPlateau": network.LRSchedulersLoader(0)
23
  },
24
  outputs_criterions: dict[str, network.TargetCriterionsLoader] = {"default": network.TargetCriterionsLoader()},
 
 
25
  ) -> None:
26
  super().__init__(
27
+ in_channels=ResEnc.IN_CHANNELS,
28
  optimizer=optimizer,
29
  schedulers=schedulers,
30
  outputs_criterions=outputs_criterions,
31
  dim=2,
32
  )
33
  self.add_module("DecoderOutputs", ResidualEncoderUNet(
34
+ input_channels=ResEnc.IN_CHANNELS,
35
  n_stages=6,
36
  features_per_stage=(24, 48, 96, 192, 256, 256),
37
  conv_op=nn.Conv2d,
38
  kernel_sizes=3,
39
  strides=(1, 2, 2, 2, 2, 2),
40
  n_blocks_per_stage=(1, 2, 2, 3, 3, 3),
41
+ num_classes=ResEnc.NUM_CLASSES,
42
  n_conv_per_stage_decoder=(1, 1, 1, 1, 1),
43
  conv_bias=True,
44
  norm_op=nn.InstanceNorm2d,
body/Prediction.yml CHANGED
@@ -2,8 +2,6 @@ Predictor:
2
  Model:
3
  classpath: Model:ResEnc
4
  ResEnc:
5
- in_channels: 5
6
- nb_class: 12
7
  outputs_criterions: None
8
  Dataset:
9
  groups_src:
 
2
  Model:
3
  classpath: Model:ResEnc
4
  ResEnc:
 
 
5
  outputs_criterions: None
6
  Dataset:
7
  groups_src: