def unet_v1(features, mode): """ U-Net: Convolutional Networks for Biomedical Image Segmentation Source: https://arxiv.org/pdf/1505.04597 """ skip_connections = [] out, skip = input_block(features, filters=64) skip_connections.append(skip) for idx, filters in enumerate([128, 256, 512]): out, skip = downsample_block(out, filters=filters, idx=idx) skip_connections.append(skip) out = bottleneck(out, filters=1024, mode=mode) for idx, filters in enumerate([512, 256, 128]): out = upsample_block(out, residual_input=skip_connections.pop(), filters=filters, idx=idx) return output_block(out, residual_input=skip_connections.pop(), filters=64, n_classes=2)
def __call__(self, features): skip_128 = input_block(x=features, out_channels=32, normalization=self._normalization, mode=self._mode) skip_64 = downsample_block(x=skip_128, out_channels=64, normalization=self._normalization, mode=self._mode) skip_32 = downsample_block(x=skip_64, out_channels=128, normalization=self._normalization, mode=self._mode) skip_16 = downsample_block(x=skip_32, out_channels=256, normalization=self._normalization, mode=self._mode) skip_8 = downsample_block(x=skip_16, out_channels=320, normalization=self._normalization, mode=self._mode) x = downsample_block(x=skip_8, out_channels=320, normalization=self._normalization, mode=self._mode) x = upsample_block(x, skip_8, out_channels=320, normalization=self._normalization, mode=self._mode) x = upsample_block(x, skip_16, out_channels=256, normalization=self._normalization, mode=self._mode) x = upsample_block(x, skip_32, out_channels=128, normalization=self._normalization, mode=self._mode) x = upsample_block(x, skip_64, out_channels=64, normalization=self._normalization, mode=self._mode) x = upsample_block(x, skip_128, out_channels=32, normalization=self._normalization, mode=self._mode) return output_layer(x=x, out_channels=self._n_classes, activation='softmax')
def __call__(self, features): x = input_block(inputs=features, filters=16, kernel_size=self._kernel_size, normalization=self._normalization, activation=self._activation, mode=self._mode) skip_connections = [x] for depth in self._downscale_blocks: x = downsample_block(inputs=x, depth=depth, kernel_size=self._kernel_size, pooling=self._pooling, normalization=self._normalization, activation=self._activation, mode=self._mode) skip_connections.append(x) del skip_connections[-1] for depth in self._upscale_blocks: x = upsample_block(inputs=x, residual_inputs=skip_connections.pop(), depth=depth, upsampling=self._upsampling, kernel_size=self._kernel_size, normalization=self._normalization, activation=self._activation, mode=self._mode) return output_block(inputs=x, residual_inputs=skip_connections.pop(), kernel_size=self._kernel_size, n_classes=self._n_classes, upsampling=self._upsampling, normalization=self._normalization, activation=self._activation, mode=self._mode)
def __call__(self, features): """ Build UNet3D :param features: Input features :return: Output of the graph """ skip_128 = input_block(inputs=features, out_channels=32, normalization=self._normalization, mode=self._mode) skip_64 = downsample_block(inputs=skip_128, out_channels=64, normalization=self._normalization, mode=self._mode) skip_32 = downsample_block(inputs=skip_64, out_channels=128, normalization=self._normalization, mode=self._mode) skip_16 = downsample_block(inputs=skip_32, out_channels=256, normalization=self._normalization, mode=self._mode) skip_8 = downsample_block(inputs=skip_16, out_channels=320, normalization=self._normalization, mode=self._mode) out = downsample_block(inputs=skip_8, out_channels=320, normalization=self._normalization, mode=self._mode) out = upsample_block(out, skip_8, out_channels=320, normalization=self._normalization, mode=self._mode) out = upsample_block(out, skip_16, out_channels=256, normalization=self._normalization, mode=self._mode) out = upsample_block(out, skip_32, out_channels=128, normalization=self._normalization, mode=self._mode) out = upsample_block(out, skip_64, out_channels=64, normalization=self._normalization, mode=self._mode) out = upsample_block(out, skip_128, out_channels=32, normalization=self._normalization, mode=self._mode) return output_layer(out, out_channels=self._n_classes, activation='softmax')