def main():
    args = get_arguments()
    os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    ## FOR REPRODUCIBILITY OF RESULTS
    seed = 1777777
    utils.reproducibility(args, seed)

    utils.make_dirs(args.save)
    utils.save_arguments(args, args.save)

    training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets(
        args, path='.././datasets')
    model, optimizer = medzoo.create_model(args)
    criterion = create_loss('CrossEntropyLoss')
    criterion = DiceLoss(classes=args.classes,
                         weight=torch.tensor([0.1, 1, 1, 1]).cuda())

    if args.cuda:
        model = model.cuda()
        print("Model transferred in GPU.....")

    trainer = Trainer(args,
                      model,
                      criterion,
                      optimizer,
                      train_data_loader=training_generator,
                      valid_data_loader=val_generator,
                      lr_scheduler=None)
    print("START TRAINING...")
    trainer.training()
def train():
    # args = brats2019_arguments()

    utils.reproducibility(args, seed)
    utils.make_dirs(args.save)

    (
        training_generator,
        val_generator,
        full_volume,
        affine,
    ) = medical_loaders.generate_datasets(args)
    model, optimizer = medzoo.create_model(args)
    val_criterion = DiceLoss(classes=11, skip_index_after=args.classes)

    # criterion = DiceLoss(classes=3, skip_index_after=args.classes)
    # criterion = DiceLoss(classes=args.classes)
    criterion = torch.nn.CrossEntropyLoss()

    if args.cuda:
        model = model.cuda()
        print("Model transferred in GPU.....")

    trainer = train_module.Trainer(
        args,
        model,
        criterion,
        optimizer,
        val_criterion=val_criterion,
        train_data_loader=training_generator,
        valid_data_loader=val_generator,
        lr_scheduler=None,
    )
    print("START TRAINING...")
    trainer.training()
Example #3
0
def main():
    args = get_arguments()

    os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    ## FOR REPRODUCIBILITY OF RESULTS
    seed = 1777777
    utils.reproducibility(args, seed)
    utils.make_dirs(args.save)
    name_model = args.model + "_" + args.dataset_name + "_" + utils.datestr()

    # TODO visual3D_temp.Basewriter package
    writer = SummaryWriter(log_dir='./runs/' + name_model, comment=name_model)

    training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets(
        args, path='.././datasets')
    model, optimizer = medzoo.create_model(args)

    if args.cuda:
        model = model.cuda()
        print("Model transferred in GPU.....")

    print("START TRAINING...")
    for epoch in range(1, args.nEpochs + 1):
        train(args, model, training_generator, optimizer, epoch, writer)
        val_metrics, confusion_matrix = validation(args, model, val_generator,
                                                   epoch, writer)
Example #4
0
def main():
    args = get_arguments()
    #os.environ["CUDA_VISIBLE_DEVICES"] = "0"
    ## FOR REPRODUCIBILITY OF RESULTS
    seed = 1777777
    utils.reproducibility(args, seed)

    training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets(
        args, path='./datasets')
    model, optimizer = medzoo.create_model(args)
    #
    criterion = DiceLoss(classes=args.classes)
    #
    # ## TODO LOAD PRETRAINED MODEL
    print(affine.shape)
    model.restore_checkpoint(args.pretrained)
    if args.cuda:
        model = model.cuda()
        full_volume = full_volume.cuda()
        print("Model transferred in GPU.....")
    x = torch.randn(3, 156, 240, 240).cuda()
    print(full_volume.shape)
    output = non_overlap_padding(args,
                                 full_volume,
                                 model,
                                 criterion,
                                 kernel_dim=(32, 32, 32))
Example #5
0
def main():
    args = get_arguments()

    utils.reproducibility(args, seed)
    utils.make_dirs(args.save)

    training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets(
        args, path='.././datasets')
    model, optimizer = medzoo.create_model(args)
    criterion = DiceLoss(classes=args.classes)

    if args.cuda:
        model = model.cuda()
        print("Model transferred in GPU.....")

    trainer = train.Trainer(args,
                            model,
                            criterion,
                            optimizer,
                            train_data_loader=training_generator,
                            valid_data_loader=val_generator,
                            lr_scheduler=None)
    print("START TRAINING...")
    trainer.training()

    visualize_3D_no_overlap_new(args, full_volume, affine, model, 10, args.dim)
Example #6
0
def main():
    args = get_arguments()
    summary_flag = True

    model_list = [
        "RESNET3DVAE", 'UNET3D', 'DENSENET1', 'DENSENET2', 'DENSENET3',
        'HYPERDENSENET', "SKIPDENSENET3D", "DENSEVOXELNET", 'VNET', 'VNET2'
    ]

    if summary_flag:
        for key in model_list:
            args.model = key
            model, _ = medzoo.create_model(args)
            print('created...', key)
def main():
    args = get_arguments()
    utils.reproducibility(args, seed)
    utils.make_dirs(args.save)

    training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets(args,
                                                                                               path='.././datasets')
    model, optimizer = medzoo.create_model(args)
    criterion = DiceLoss(classes=args.classes)

    if args.cuda:
        model = model.cuda()

    trainer = train.Trainer(args, model, criterion, optimizer, train_data_loader=training_generator,
                            valid_data_loader=val_generator)
    trainer.training()
def main():
    args = get_arguments()
    utils.reproducibility(args, seed)
    utils.make_dirs(args.save)

    training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets(
        args, path='.././datasets')
    model, optimizer = medzoo.create_model(args)
    criterion = DiceLoss(
        classes=args.classes
    )  # ,skip_index_after=2,weight=torch.tensor([0.00001,1,1,1]).cuda())

    if args.cuda:
        model = model.cuda()
        print("Model transferred in GPU.....")

    trainer = train.Trainer(args,
                            model,
                            criterion,
                            optimizer,
                            train_data_loader=training_generator,
                            valid_data_loader=val_generator)
    print("START TRAINING...")
    trainer.training()