我正在为图像分割创建一个unet-在城市的航拍上为建筑物创建地面真相((5000,5000,3)我减少到(4992,4992,3)的图像以允许多个采样),而我的输出要么是几乎完全空白的图像,要么是一帧随机噪声(取决于我调整层数的方式),但从未给出适当的解决方案
我看到的常见修复方法是确保像素被归一化(它们是)并减少层数-两者都使我无处可去
我的unet定义为
def Unet():
input = keras.layers.Input((4992, 4992, 3))
p0 = input
c1,p1 = down_conv(p0,1)
c2,p2 = down_conv(p1,2)
c3,p3 = down_conv(p2,4)
c4,p4 = down_conv(p3,8)
bn = bottleneck(p4,16)
u1 = up_conv(bn,c4,8)
u2 = up_conv(u1,c3,4)
u3 = up_conv(u2,c2,2)
u4 = up_conv(u3,c1,1)
out = keras.layers.Conv2D(1,(1,1), padding = "same", activation = "sigmoid")(u4)
model = keras.models.Model(input,out)
return model
具有功能
def down_conv(x,filters,kernel_size=(3,3), padding = "same",strides = 1):
x = keras.layers.Conv2D(filters,kernel_size,padding=padding,strides=strides,activation="relu")(x)
x = keras.layers.Conv2D(filters,kernel_size,padding=padding,strides=strides,activation="relu")(x)
p = keras.layers.MaxPool2D((2,2),(2,2))(x)
return x,p
def up_conv(x,skip,filters,kernel_size=(3,3),padding = "same",strides = 1):
x = keras.layers.UpSampling2D((2,2))(x)
x = keras.layers.Concatenate()([x,skip])
x = keras.layers.Conv2D(filters,kernel_size,padding=padding,strides=strides,activation="relu")(x)
x = keras.layers.Conv2D(filters,kernel_size,padding=padding,strides=strides,activation="relu")(x)
return x
def bottleneck(x,filters,kernel_size=(3,3), padding = "same",strides = 1):
x = keras.layers.Conv2D(filters,kernel_size,padding=padding,strides=strides,activation="relu")(x)
x = keras.layers.Conv2D(filters,kernel_size,padding=padding,strides=strides,activation="relu")(x)
return x