def Atrous_DenseNet(input_shape=None, weight_decay=1E-4,
batch_momentum=0.9, batch_shape=None, classes=21,
include_top=False, activation='sigmoid'):
# TODO(ahundt) pass the parameters but use defaults for now
if include_top is True:
# TODO(ahundt) Softmax is pre-applied, so need different train, inference, evaluate.
# TODO(ahundt) for multi-label try per class sigmoid top as follows:
# x = Reshape((row * col * classes))(x)
# x = Activation('sigmoid')(x)
# x = Reshape((row, col, classes))(x)
return densenet.DenseNet(depth=None, nb_dense_block=3, growth_rate=32,
nb_filter=-1, nb_layers_per_block=[6, 12, 24, 16],
bottleneck=True, reduction=0.5, dropout_rate=0.2,
weight_decay=1E-4,
include_top=True, top='segmentation',
weights=None, input_tensor=None,
input_shape=input_shape,
classes=classes, transition_dilation_rate=2,
transition_kernel_size=(1, 1),
transition_pooling=None)
# if batch_shape:
# img_input = Input(batch_shape=batch_shape)
# image_size = batch_shape[1:3]
# else:
# img_input = Input(shape=input_shape)
# image_size = input_shape[0:2]
input_shape = _obtain_input_shape(input_shape,
default_size=32,
min_size=16,
data_format=K.image_data_format(),
include_top=False)
img_input = Input(shape=input_shape)
x = densenet.__create_dense_net(classes, img_input,
depth=None, nb_dense_block=3, growth_rate=32,
nb_filter=-1, nb_layers_per_block=[6, 12, 24, 16],
bottleneck=True, reduction=0.5, dropout_rate=0.2,
weight_decay=1E-4, top='segmentation',
input_shape=input_shape,
transition_dilation_rate=2,
transition_kernel_size=(1, 1),
transition_pooling=None,
include_top=include_top)
x = top(x, input_shape, classes, activation, weight_decay)
model = Model(img_input, x, name='Atrous_DenseNet')
# TODO(ahundt) add weight loading
return model
评论列表
文章目录