赞
踩
论文标题:
U-Net: Convolutional Networks for Biomedical Image Segmentation
虽然主要运用医学领域但是在其他领域效果也很好。
U-Net网络非常简单,前半部分作用是特征提取,后半部分是上采样。在一些文献中也把这样的结构叫做编码器-解码器结构。由于此网络整体结构类似于大写的英文字母U,故得名U-net。
U-Net与其他常见的分割网络有一点非常不同的地方:U-net采用了完全不同的特征融合方式:拼接,U-net采用将特征在channel维度拼接在一起,形成更厚的特征。而FCN融合时使用的对应点相加,并不形成更厚的特征。
U-Net只是一个网络结构的代号而已,只要符合此类特点都可以叫U-Net。
根据论文原文:
我们把U-Net的左边叫做: contracting path
我们把U-Net的右边叫做: expanding path
contracting path:常规的特征提取网络, 一直down sampling的过程,只是提供了四层的特征输出。
expanding path:一直up sampling的过程,堆叠contracting path提供的四层特征,输出一张tensor
语义分割:就是对像素的分类。
直接写代码,我们迁移VGG16完成,contracting path的实现。
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import datasets, layers, optimizers, Sequential, models, applications
baseModel = applications.VGG16(weights="imagenet",include_top=False,input_shape = (512, 512, 3),pooling=None)
baseModel.trainable = False
contractingNet = models.Model(inputs=baseModel.input, outputs=baseModel.get_layer('block4_pool').output)
contractingNet.summary()
f1 = contractingNet.get_layer("block1_conv2").output
f2 = contractingNet.get_layer("block2_conv2").output
f3 = contractingNet.get_layer("block3_conv3").output
f4 = contractingNet.get_layer("block4_conv3").output
expanding path实现:
a = layers.Conv2D(1024, kernel_size=[3, 3], padding="same", activation="relu")(contractingNet.output) a = layers.Conv2D(512, kernel_size=[1, 1], padding="same", activation="relu")(a) a = layers.Conv2D(1024, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.UpSampling2D(size = (2,2))(a) a = layers.concatenate([a,f4], axis = -1) a = layers.Conv2D(512, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.Conv2D(256, kernel_size=[1, 1], padding="same", activation="relu")(a) a = layers.Conv2D(512, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.UpSampling2D(size = (2,2))(a) a = layers.concatenate([a,f3], axis = -1) a = layers.Conv2D(256, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.Conv2D(128, kernel_size=[1, 1], padding="same", activation="relu")(a) a = layers.Conv2D(256, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.UpSampling2D(size = (2,2))(a) a = layers.concatenate([a,f2], axis = -1) a = layers.Conv2D(128, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.Conv2D(64, kernel_size=[1, 1], padding="same", activation="relu")(a) a = layers.Conv2D(128, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.UpSampling2D(size = (2,2))(a) a = layers.concatenate([a,f1], axis = -1) a = layers.Conv2D(64, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.Conv2D(32, kernel_size=[1, 1], padding="same", activation="relu")(a) a = layers.Conv2D(64, kernel_size=[3, 3], padding="same", activation="relu")(a) a = layers.Conv2D(8, kernel_size=[3, 3], padding="same", activation="relu")(a) outputs = layers.Conv2D(1, kernel_size=[1, 1], padding="same", activation="sigmoid")(a)
就这样实现了一个自己的U-Net网络了。
再看看自己写的U-Net训练完的效果图。
论文:http://www.arxiv.org/pdf/1505.04597.pdf
源代码:https://github.com/wuyouyin/tensorflow2-unet
dataset_cell:https://pan.baidu.com/s/1PfOMxGUwJhO-9p8yDsasag 提取码:nqhh
dataset_sidewalk:https://pan.baidu.com/s/1SZ42yGLNf2C9XUNUQkQCbw 提取码:ntyh
dataset_trafficRoad:https://pan.baidu.com/s/1mFFAx7dPcrdkXsbGQomGRg 提取码:20oh
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。