U-Net: Convolutional Networks for Biomedical Image Segmentation

https://arxiv.org/abs/1505.04597
https://www.seoxiehui.cn/article-106308-1.html

简介:介绍在图像分割中,机器必须将图像分割成不同的segments,每个segment代表不同的实体。图像分割示例正如你在上面看到的,图像如何变成两个部分,一个代表猫,另一个代表背景。图像分割在从自动驾驶汽车到卫星的许多 ...

介绍

在图像分割中,机器必须将图像分割成不同的segments,每个segment代表不同的实体。


U-Net: Convolutional Networks for Biomedical Image Segmentation_第1张图片
image.png

图像分割在从自动驾驶汽车到卫星的许多领域都很有用。也许其中最重要的是医学影像。医学图像的微妙之处是相当复杂的。一台能够理解这些细微差别并识别出必要区域的机器,可以对医疗保健产生深远的影响。

卷积神经网络在简单的图像分割问题上取得了不错的效果,但在复杂的图像分割问题上却没有取得任何进展。这就是UNet的作用。UNet最初是专门为医学图像分割而设计的。该方法取得了良好的效果,并在以后的许多领域得到了应用。在本文中,我们将讨论UNet工作的原因和方式

UNet架构

U-Net: Convolutional Networks for Biomedical Image Segmentation_第2张图片
image.png

该架构看起来像一个'U'。该体系结构由三部分组成:contraction,bottleneck和expansion 部分。contraction部分由许多contraction块组成。每个块接受一个输入,应用两个3X3的卷积层,然后是一个2X2的最大池化。在每个块之后,核或特征映射的数量会加倍,这样体系结构就可以有效地学习复杂的结构。最底层介于contraction层和expansion 层之间。它使用两个3X3 CNN层,然后是2X2 up convolution层。

这种架构的核心在于expansion 部分。与contraction层类似,它也包含几个expansion 块。每个块将输入传递到两个3X3 CNN层,然后是2X2上采样层。此外,卷积层使用的每个块的feature map数量得到一半,以保持对称性。每次输入也被相应的收缩层的 feature maps所附加。这个动作将确保在contracting 图像时学习到的特征将被用于重建图像。expansion 块的数量与contraction块的数量相同。之后,生成的映射通过另一个3X3 CNN层,feature map的数量等于所需的segment的数量。

UNet中的损失计算

UNet对每个像素使用了一种新颖的损失加权方案,使得分割对象的边缘具有更高的权重。这种损失加权方案帮助U-Net模型以不连续的方式分割生物医学图像中的细胞,以便在binary segmentation map中容易识别单个细胞。

首先,在所得图像上应用pixel-wise softmax,然后是交叉熵损失函数。所以我们将每个像素分类为一个类。我们的想法是,即使在分割中,每个像素都必须存在于某个类别中,我们只需要确保它们可以。因此,我们只是将分段问题转换为多类分类问题,与传统的损失函数相比,它表现得非常好。

def unet(pretrained_weights = None,input_size = (256,256,1)):
    inputs = Input(input_size)
    conv1 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(inputs)
    conv1 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv1)
    pool1 = MaxPooling2D(pool_size=(2, 2))(conv1)
    conv2 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool1)
    conv2 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv2)
    pool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
    conv3 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool2)
    conv3 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv3)
    pool3 = MaxPooling2D(pool_size=(2, 2))(conv3)
    conv4 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool3)
    conv4 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv4)
    drop4 = Dropout(0.5)(conv4)
    pool4 = MaxPooling2D(pool_size=(2, 2))(drop4)

    conv5 = Conv2D(1024, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(pool4)
    conv5 = Conv2D(1024, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv5)
    drop5 = Dropout(0.5)(conv5)

    up6 = Conv2D(512, 2, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(UpSampling2D(size = (2,2))(drop5))
    merge6 = concatenate([drop4,up6], axis = 3)
    conv6 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(merge6)
    conv6 = Conv2D(512, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv6)

    up7 = Conv2D(256, 2, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(UpSampling2D(size = (2,2))(conv6))
    merge7 = concatenate([conv3,up7], axis = 3)
    conv7 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(merge7)
    conv7 = Conv2D(256, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv7)

    up8 = Conv2D(128, 2, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(UpSampling2D(size = (2,2))(conv7))
    merge8 = concatenate([conv2,up8], axis = 3)
    conv8 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(merge8)
    conv8 = Conv2D(128, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv8)

    up9 = Conv2D(64, 2, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(UpSampling2D(size = (2,2))(conv8))
    merge9 = concatenate([conv1,up9], axis = 3)
    conv9 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(merge9)
    conv9 = Conv2D(64, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv9)
    conv9 = Conv2D(2, 3, activation = 'relu', padding = 'same', kernel_initializer = 'he_normal')(conv9)
    conv10 = Conv2D(1, 1, activation = 'sigmoid')(conv9)

    model = Model(input = inputs, output = conv10)

    model.compile(optimizer = Adam(lr = 1e-4), loss = 'binary_crossentropy', metrics = ['accuracy'])
    
    #model.summary()

    if(pretrained_weights):
        model.load_weights(pretrained_weights)

    return model

你可能感兴趣的:(U-Net: Convolutional Networks for Biomedical Image Segmentation)