Update body model
Browse files- body/Body.pt +2 -2
- body/Model.py +19 -23
- body/Prediction.yml +3 -3
body/Body.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be2218b50786e326e38c65c5cf2e2745f354911acbb4ae86bd1ca702db316d1c
|
| 3 |
+
size 47484709
|
body/Model.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from torch import nn
|
| 3 |
-
|
| 4 |
from dynamic_network_architectures.architectures.unet import ResidualEncoderUNet
|
| 5 |
from konfai.network import network
|
| 6 |
|
| 7 |
-
|
| 8 |
def _replace_unpicklable_identities(module: nn.Module) -> None:
|
| 9 |
"""Replace library lambdas such as ``lambda x: x`` with ``nn.Identity``."""
|
| 10 |
for child in module.modules():
|
|
@@ -13,7 +9,7 @@ def _replace_unpicklable_identities(module: nn.Module) -> None:
|
|
| 13 |
if hasattr(child, "nonlin2") and callable(child.nonlin2) and not isinstance(child.nonlin2, nn.Module):
|
| 14 |
child.nonlin2 = nn.Identity()
|
| 15 |
|
| 16 |
-
class
|
| 17 |
def __init__(
|
| 18 |
self,
|
| 19 |
optimizer: network.OptimizerLoader = network.OptimizerLoader(),
|
|
@@ -32,22 +28,22 @@ class ResEncMCT(network.Network):
|
|
| 32 |
dim=2,
|
| 33 |
)
|
| 34 |
self.add_module("DecoderOutputs", ResidualEncoderUNet(
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
_replace_unpicklable_identities(self.DecoderOutputs)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from dynamic_network_architectures.architectures.unet import ResidualEncoderUNet
|
| 2 |
from konfai.network import network
|
| 3 |
|
|
|
|
| 4 |
def _replace_unpicklable_identities(module: nn.Module) -> None:
|
| 5 |
"""Replace library lambdas such as ``lambda x: x`` with ``nn.Identity``."""
|
| 6 |
for child in module.modules():
|
|
|
|
| 9 |
if hasattr(child, "nonlin2") and callable(child.nonlin2) and not isinstance(child.nonlin2, nn.Module):
|
| 10 |
child.nonlin2 = nn.Identity()
|
| 11 |
|
| 12 |
+
class ResEnc(network.Network):
|
| 13 |
def __init__(
|
| 14 |
self,
|
| 15 |
optimizer: network.OptimizerLoader = network.OptimizerLoader(),
|
|
|
|
| 28 |
dim=2,
|
| 29 |
)
|
| 30 |
self.add_module("DecoderOutputs", ResidualEncoderUNet(
|
| 31 |
+
input_channels=in_channels,
|
| 32 |
+
n_stages=6,
|
| 33 |
+
features_per_stage=(24, 48, 96, 192, 256, 256),
|
| 34 |
+
conv_op=nn.Conv2d,
|
| 35 |
+
kernel_sizes=3,
|
| 36 |
+
strides=(1, 2, 2, 2, 2, 2),
|
| 37 |
+
n_blocks_per_stage=(1, 2, 2, 3, 3, 3),
|
| 38 |
+
num_classes=nb_class,
|
| 39 |
+
n_conv_per_stage_decoder=(1, 1, 1, 1, 1),
|
| 40 |
+
conv_bias=True,
|
| 41 |
+
norm_op=nn.InstanceNorm2d,
|
| 42 |
+
norm_op_kwargs={"eps": 1e-5, "affine": True},
|
| 43 |
+
dropout_op=None,
|
| 44 |
+
dropout_op_kwargs=None,
|
| 45 |
+
nonlin=nn.LeakyReLU,
|
| 46 |
+
nonlin_kwargs={"inplace": True},
|
| 47 |
+
deep_supervision=False,
|
| 48 |
+
))
|
| 49 |
_replace_unpicklable_identities(self.DecoderOutputs)
|
body/Prediction.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
Predictor:
|
| 2 |
Model:
|
| 3 |
-
classpath: Model:
|
| 4 |
-
|
| 5 |
in_channels: 5
|
| 6 |
nb_class: 12
|
| 7 |
outputs_criterions: None
|
|
@@ -18,7 +18,7 @@ Predictor:
|
|
| 18 |
spacing:
|
| 19 |
- 3
|
| 20 |
- 3
|
| 21 |
-
-
|
| 22 |
inverse: true
|
| 23 |
Standardize:
|
| 24 |
lazy: false
|
|
|
|
| 1 |
Predictor:
|
| 2 |
Model:
|
| 3 |
+
classpath: Model:ResEnc
|
| 4 |
+
ResEnc:
|
| 5 |
in_channels: 5
|
| 6 |
nb_class: 12
|
| 7 |
outputs_criterions: None
|
|
|
|
| 18 |
spacing:
|
| 19 |
- 3
|
| 20 |
- 3
|
| 21 |
+
- 3
|
| 22 |
inverse: true
|
| 23 |
Standardize:
|
| 24 |
lazy: false
|