napari_cellseg3d.code_models.models.wnet.model
Implementation of a 3D W-Net model, based on the 2D version from https://arxiv.org/abs/1711.08506. The model performs unsupervised segmentation of 3D images.
Classes:
| Name | Description |
|---|---|
Block |
Basic block of the U-Net architecture. |
InBlock |
Input block of the U-Net architecture. |
OutBlock |
Output block of the U-Net architecture. |
UNet |
Half of the W-Net model, based on the U-Net architecture. |
WNet |
Implementation of a 3D W-Net model, based on the 2D version from https://arxiv.org/abs/1711.08506. |
WNet_encoder |
WNet3D with encoder only. |
Block
Bases: Module
Basic block of the U-Net architecture.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the basic block. |
forward |
Forward pass of the basic block. |
Source code in napari_cellseg3d/code_models/models/wnet/model.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
__init__
__init__(in_channels, out_channels, dropout=0.65)
Initialize the basic block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_channels
|
int
|
Number of input channels. |
required |
out_channels
|
int
|
Number of output channels. |
required |
dropout
|
float
|
Dropout probability. Defaults to 0.65. |
0.65
|
Source code in napari_cellseg3d/code_models/models/wnet/model.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
forward
forward(x)
Forward pass of the basic block.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
236 237 238 | |
InBlock
Bases: Module
Input block of the U-Net architecture.
Methods:
| Name | Description |
|---|---|
__init__ |
Create the input block. |
forward |
Forward pass of the input block. |
Source code in napari_cellseg3d/code_models/models/wnet/model.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
__init__
__init__(in_channels, out_channels, dropout=0.65)
Create the input block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_channels
|
int
|
Number of input channels. |
required |
out_channels
|
int
|
Number of output channels. |
required |
dropout
|
float
|
Dropout probability. Defaults to 0.65. |
0.65
|
Source code in napari_cellseg3d/code_models/models/wnet/model.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
forward
forward(x)
Forward pass of the input block.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
203 204 205 | |
OutBlock
Bases: Module
Output block of the U-Net architecture.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the output block. |
forward |
Forward pass of the output block. |
Source code in napari_cellseg3d/code_models/models/wnet/model.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
__init__
__init__(in_channels, out_channels, dropout=0.65)
Initialize the output block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_channels
|
int
|
Number of input channels. |
required |
out_channels
|
int
|
Number of output channels. |
required |
dropout
|
float
|
Dropout probability. Defaults to 0.65. |
0.65
|
Source code in napari_cellseg3d/code_models/models/wnet/model.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
forward
forward(x)
Forward pass of the output block.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
268 269 270 | |
UNet
Bases: Module
Half of the W-Net model, based on the U-Net architecture.
Methods:
| Name | Description |
|---|---|
__init__ |
Creates a U-Net model, which is half of the W-Net model. |
forward |
Forward pass of the U-Net model. |
Source code in napari_cellseg3d/code_models/models/wnet/model.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
__init__
__init__(in_channels: int, out_channels: int, channels: List[int] = None, softmax: bool = True, dropout: float = 0.65)
Creates a U-Net model, which is half of the W-Net model.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
forward
forward(x)
Forward pass of the U-Net model.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
WNet
Bases: Module
Implementation of a 3D W-Net model, based on the 2D version from https://arxiv.org/abs/1711.08506.
The model performs unsupervised segmentation of 3D images. It first encodes the input image into a latent space using the U-Net UEncoder, then decodes it back to the original image using the U-Net UDecoder.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the W-Net model. |
forward |
Forward pass of the W-Net model. Returns the segmentation and the reconstructed image. |
forward_decoder |
Forward pass of the decoder part of the W-Net model. |
forward_encoder |
Forward pass of the encoder part of the W-Net model. |
Source code in napari_cellseg3d/code_models/models/wnet/model.py
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 | |
__init__
__init__(in_channels=1, out_channels=2, num_classes=2, dropout=0.65)
Initialize the W-Net model.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
49 50 51 52 53 54 55 56 57 58 59 | |
forward
forward(x)
Forward pass of the W-Net model. Returns the segmentation and the reconstructed image.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
61 62 63 64 | |
forward_decoder
forward_decoder(enc)
Forward pass of the decoder part of the W-Net model.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
70 71 72 | |
forward_encoder
forward_encoder(x)
Forward pass of the encoder part of the W-Net model.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
66 67 68 | |
WNet_encoder
Bases: Module
WNet3D with encoder only.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the W-Net encoder. |
forward |
Forward pass of the W-Net model. |
Source code in napari_cellseg3d/code_models/models/wnet/model.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
__init__
__init__(in_channels=1, out_channels=2, softmax=True)
Initialize the W-Net encoder.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
forward
forward(x)
Forward pass of the W-Net model.
Source code in napari_cellseg3d/code_models/models/wnet/model.py
37 38 39 | |