def get_model(n_classes, class_weights, unsuper_weight=0): i = Input((None, None, 3)) t = bn_block(i) feat_list = [t] for layer in range(0, 3): t = conv_block(t, 32, (3, 3)) feat_list.append(t) t = Dropout(0.15)(t) t = conv_block(t, 128, (1, 1)) t = conv_block(t, 32, (1, 1)) t = Conv2D(n_classes, (1, 1))(t) o1 = Softmax4D()(t) model = Model(inputs=[i], outputs=[o1]) loss = M.loss(weights=class_weights, unsuper_weight=unsuper_weight, unsuper_channel=-1) wcce = M.wcceOA(weights=class_weights) uentr = M.entrONA(unsuper_channel=-1) wacc = M.waccOA(weights=class_weights) model.compile(optimizer=Adam(0.01), loss=loss, metrics=[wcce, uentr, wacc]) return model
def get_model(n_classes, class_weights, unsuper_weight=0): atrous_rates = [(1, 1), (1, 1), (2, 2), (3, 3), (5, 5), (8, 8), (13, 13), (21, 21), (34, 34), (55, 55)] i = Input((None, None, 3)) t = bn_block(i) feat_list = [t] for layer in range(0, len(atrous_rates)): t = conv_block(t, 32, (3, 3), atrous_rate=atrous_rates[layer]) feat_list.append(t) t = Concatenate(axis=-1)(feat_list) t = Dropout(0.5)(t) t = conv_block(t, 128, (1, 1)) t = conv_block(t, 32, (1, 1)) t = Conv2D(n_classes, (1, 1), kernel_initializer='he_normal')(t) o1 = Softmax4D()(t) model = Model(inputs=[i], outputs=[o1]) loss = M.loss(weights=class_weights, unsuper_weight=unsuper_weight, unsuper_channel=-1) wcce = M.wcceOA(weights=class_weights) uentr = M.entrONA(unsuper_channel=-1) wacc = M.waccOA(weights=class_weights) model.compile(optimizer=Adam(0.01), loss=loss, metrics=[wcce, uentr, wacc]) return model
def get_model(n_classes, class_weights, unsuper_weight=0): model = models.Sequential() model.add( layers.Conv2D(64, (3, 3), activation='relu', input_shape=(None, None, 3), padding='same')) model.add(layers.MaxPooling2D((2, 2))) model.add(layers.Conv2D(64, (3, 3), activation='relu', padding='same')) model.add(layers.MaxPooling2D((2, 2))) model.add(layers.Conv2D(64, (3, 3), activation='relu', padding='same')) model.add(layers.MaxPooling2D((2, 2))) model.add(layers.Conv2D(64, (1, 1), activation='relu', padding='same')) model.add(layers.Conv2D(n_classes, (1, 1), activation='relu')) model.add(UpSampling2D((8, 8))) model.add(Softmax4D()) #model = Model(inputs=[i], outputs=[o1]) loss = M.loss(weights=class_weights, unsuper_weight=unsuper_weight, unsuper_channel=-1) wcce = M.wcceOA(weights=class_weights) uentr = M.entrONA(unsuper_channel=-1) wacc = M.waccOA(weights=class_weights) model.compile(optimizer=Adam(0.01), loss=loss, metrics=[wcce, uentr, wacc]) return model
def get_model(n_classes, class_weights, unsuper_weight=0): i = Input((None, None, 3)) #encoding layers o = (ZeroPadding2D((1, 1)))(i) o = (Convolution2D(64, (3, 3), padding='valid'))(o) o = (BatchNormalization())(o) o = (MaxPooling2D(pool_size=(2, 2)))(o) o = (ZeroPadding2D((1, 1)))(o) o = (Convolution2D(128, (3, 3), padding='valid'))(o) o = (Activation('relu'))(o) o = (BatchNormalization())(o) o = (MaxPooling2D(pool_size=(2, 2)))(o) o = (ZeroPadding2D((1, 1)))(o) o = (Convolution2D(256, (3, 3), padding='valid'))(o) o = (Activation('relu'))(o) o = (BatchNormalization())(o) o = (MaxPooling2D(pool_size=(2, 2)))(o) o = (ZeroPadding2D((1, 1)))(o) o = (Convolution2D(512, (3, 3), padding='valid'))(o) o = (Activation('relu'))(o) o = (BatchNormalization())(o) #decoding layers o = (ZeroPadding2D((1, 1)))(o) o = (Convolution2D(512, (3, 3), padding='valid'))(o) o = (BatchNormalization())(o) o = (UpSampling2D((2, 2)))(o) o = (ZeroPadding2D((1, 1)))(o) o = (Convolution2D(256, (3, 3), padding='valid'))(o) o = (BatchNormalization())(o) o = (UpSampling2D((2, 2)))(o) o = (ZeroPadding2D((1, 1)))(o) o = (Convolution2D(128, (3, 3), padding='valid'))(o) o = (BatchNormalization())(o) o = (UpSampling2D((2, 2)))(o) o = (ZeroPadding2D((1, 1)))(o) o = (Convolution2D(64, (3, 3), padding='valid'))(o) o = (BatchNormalization())(o) o = (Convolution2D(n_classes, (1, 1), padding='valid'))(o) o1 = Softmax4D()(o) model = Model(inputs=[i], outputs=[o1]) loss = M.loss(weights=class_weights, unsuper_weight=unsuper_weight, unsuper_channel=-1) wcce = M.wcceOA(weights=class_weights) uentr = M.entrONA(unsuper_channel=-1) wacc = M.waccOA(weights=class_weights) model.compile(optimizer=Adam(0.01), loss=loss, metrics=[wcce, uentr, wacc]) return model