net = module(feature_maps=args.fm, levels=args.levels, norm=args.norm, activation=args.activation, coi=args.classes_of_interest) net.load_state_dict(net_state) break except RuntimeError: continue return net net = _load_net(args.net, args.device) if net.__class__ != UNet2D: net = net.get_unet() """ Validate the trained network """ validate(net, test_src.data, test_src.labels, args.input_size, batch_size=args.test_batch_size, track_progress=True, write_dir=os.path.join(args.log_dir, 'segmentation'), val_file=os.path.join(args.log_dir, 'validation.npy'), device=args.device) print('[%s] Finished!' % (datetime.datetime.now()))
test_loader_tar_ul, test_loader_tar_l, optimizer, args.epochs, scheduler=scheduler, augmenter=augmenter, print_stats=args.print_stats, log_dir=args.log_dir, device=args.device) """ Validate the trained network """ validate(net.get_unet(), test_tar_l.data, test_tar_l.labels, args.input_size, batch_size=args.test_batch_size, write_dir=os.path.join(args.log_dir, 'segmentation_final'), val_file=os.path.join(args.log_dir, 'validation_final.npy'), classes_of_interest=args.classes_of_interest) net.load_state_dict( torch.load(os.path.join(args.log_dir, 'best_checkpoint.pytorch'))) validate(net.get_unet(), test_tar_l.data, test_tar_l.labels, args.input_size, batch_size=args.test_batch_size, write_dir=os.path.join(args.log_dir, 'segmentation_best'), val_file=os.path.join(args.log_dir, 'validation_best.npy'), classes_of_interest=args.classes_of_interest) print('[%s] Finished!' % (datetime.datetime.now()))
loss_fn, optimizer, args.epochs, scheduler=scheduler, augmenter=augmenter, print_stats=args.print_stats, log_dir=args.log_dir, device=args.device) """ Validate the trained network """ validate(net, test.data, test.labels, args.input_size, batch_size=args.test_batch_size, write_dir=os.path.join(args.log_dir, 'segmentation_final'), classes_of_interest=args.classes_of_interest, val_file=os.path.join(args.log_dir, 'validation_final.npy'), in_channels=args.in_channels) net = torch.load(os.path.join(args.log_dir, 'best_checkpoint.pytorch')) validate(net, test.data, test.labels, args.input_size, batch_size=args.test_batch_size, write_dir=os.path.join(args.log_dir, 'segmentation_best'), classes_of_interest=args.classes_of_interest, val_file=os.path.join(args.log_dir, 'validation_best.npy'), in_channels=args.in_channels)