napari_cellseg3d.code_models.models.model_WNet
Wrapper for the W-Net model, with the decoder weights removed.
.. important:: Used for inference only. For training the base class is used.
Classes:
| Name | Description |
|---|---|
WNet_ |
W-Net wrapper for napari_cellseg3d. |
Attributes:
| Name | Type | Description |
|---|---|---|
NUM_CLASSES_KEY |
State-dict key of the encoder's final conv bias, whose length is the number of classes. |
NUM_CLASSES_KEY
module-attribute
NUM_CLASSES_KEY = 'encoder.out_b.module.8.bias'
State-dict key of the encoder's final conv bias, whose length is the number of classes.
WNet_
Bases: WNet_encoder
W-Net wrapper for napari_cellseg3d.
..important:: Used for inference only, therefore only the encoder is used. For training the base class is used.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a W-Net model. |
forward |
Forward pass of the W-Net model. |
load_state_dict |
Load the model state dict for inference, without the decoder weights. |
num_classes_from_weights |
Number of encoder output classes stored in a .pth weights file, or None if it cannot be read. |
Attributes:
| Name | Type | Description |
|---|---|---|
default_channel |
Foreground channel of the pretrained weights. |
Source code in napari_cellseg3d/code_models/models/model_WNet.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
default_channel
class-attribute
instance-attribute
default_channel = 1
Foreground channel of the pretrained weights.
__init__
__init__(in_channels=1, out_channels=2, **kwargs)
Create a W-Net model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_channels
|
int
|
number of input channels |
1
|
out_channels
|
int
|
number of output channels. |
2
|
**kwargs
|
additional arguments to WNet_encoder. |
{}
|
Source code in napari_cellseg3d/code_models/models/model_WNet.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
forward
forward(x)
Forward pass of the W-Net model.
Source code in napari_cellseg3d/code_models/models/model_WNet.py
56 57 58 59 | |
load_state_dict
load_state_dict(state_dict, strict=True)
Load the model state dict for inference, without the decoder weights.
Source code in napari_cellseg3d/code_models/models/model_WNet.py
79 80 81 82 83 84 85 86 | |
num_classes_from_weights
staticmethod
num_classes_from_weights(weights_path) -> Optional[int]
Number of encoder output classes stored in a .pth weights file, or None if it cannot be read.
Source code in napari_cellseg3d/code_models/models/model_WNet.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |