Esempio n. 1
0
if TRAIN:
    for fold in range(1, folds):

        train, test = dl.get_k_split(fold)

        tr, val = train_test_split(train, test_size=.15, random_state=43)
        gen, test_gen = create_gens(tr, val)

        model = UNet3D_Extra(input_shape=(1, 128, 128, 128), n_labels=1)
        model.compile(optimizer=keras.optimizers.adam(.001), loss=loss_func)

        callbacks = get_callbacks(model_file=main_dr + 'saved_models/Leak-' +
                                  str(fold) + '.h5',
                                  initial_learning_rate=5e-3,
                                  learning_rate_drop=.5,
                                  learning_rate_epochs=None,
                                  learning_rate_patience=10,
                                  verbosity=1,
                                  early_stopping_patience=30)

        model.fit_generator(generator=gen,
                            validation_data=test_gen,
                            use_multiprocessing=True,
                            workers=8,
                            epochs=epochs,
                            callbacks=callbacks)

        #model.save_weights(main_dr + 'saved_models/Leak-' + str(fold) + '.h5')

if EVAL:
Esempio n. 2
0
model = CNN_3D_AE(input_dims, 200)
model.compile(loss='binary_crossentropy',
              optimizer=keras.optimizers.adam(initial_lr))

if load:
    model.load_weights(model_path)
    print('loaded weights')

model.summary()
gen, test_gen = create_gens(train, test)

callbacks = get_callbacks(model_file=model_path,
                          initial_learning_rate=initial_lr,
                          learning_rate_drop=.5,
                          learning_rate_epochs=None,
                          learning_rate_patience=100,
                          verbosity=1,
                          early_stopping_patience=100)

model.fit_generator(generator=gen,
                    validation_data=test_gen,
                    use_multiprocessing=True,
                    workers=8,
                    epochs=epochs,
                    callbacks=callbacks)

preds = model.predict_generator(test_gen)

for i in range(5):
    ex = preds[i]
Esempio n. 3
0
                         n_classes=1,
                         shuffle=True,
                         augment=True,
                         label_size=5)

test_gen = RN_Generator(data_points=val,
                        dim=config['RN_input_size'],
                        batch_size=bs,
                        n_classes=1,
                        shuffle=False,
                        augment=False,
                        label_size=5)

callbacks = get_callbacks(model_file=main_dr + 'saved_models/RN.h5',
                          initial_learning_rate=initial_lr,
                          learning_rate_drop=.5,
                          learning_rate_epochs=None,
                          learning_rate_patience=10,
                          verbosity=1,
                          early_stopping_patience=50)

#model = load_RN_model('/home/sage/GenDiagFramework/saved_models/RN.h5')

model = RetinaNet_Train()
model.fit_generator(generator=train_gen,
                    validation_data=test_gen,
                    use_multiprocessing=True,
                    workers=8,
                    epochs=25,
                    callbacks=callbacks)