def DenseNet_FCN(input_shape=None, weight_decay=0., batch_momentum=0.9, batch_shape=None, classes=21): return densenet.DenseNetFCN(input_shape=input_shape, weights=None, classes=classes)
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
def DenseNet_FCN(self, weight_decay=1E-4, batch_momentum=0.9, batch_shape=None, include_top=True, activation='sigmoid'): classes = self.classes if include_top is True: 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) init_img_input = Input(shape=(self.height, self.width, self.channels)) input_shape = _obtain_input_shape(init_img_input, default_size=0.5 * self.features, 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 = self.top(x, input_shape, classes, activation, weight_decay) model = Model(img_input, x, name='DenseNet_FCN') return model