def DenseNet_FCN(input_shape=None, weight_decay=1E-4,
batch_momentum=0.9, batch_shape=None, classes=21,
include_top=False, activation='sigmoid'):
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.DenseNetFCN(input_shape=input_shape,
weights=None, classes=classes,
nb_layers_per_block=[4, 5, 7, 10, 12, 15],
growth_rate=16,
dropout_rate=0.2)
# 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_fcn_dense_net(classes, img_input,
input_shape=input_shape,
nb_layers_per_block=[4, 5, 7, 10, 12, 15],
growth_rate=16,
dropout_rate=0.2,
include_top=include_top)
x = top(x, input_shape, classes, activation, weight_decay)
# TODO(ahundt) add weight loading
model = Model(img_input, x, name='DenseNet_FCN')
return model
评论列表
文章目录