exit(0) if len(args.gpus) > 0: os.environ['CUDA_VISIBLE_DEVICES'] = args.gpus torch_devs = torch.device("cuda" if torch.cuda.is_available() else "cpu") itr_out_dir = args.expName + '-itrOut' if os.path.isdir(itr_out_dir): shutil.rmtree(itr_out_dir) os.mkdir(itr_out_dir) # to save temp output # redirect print to a file if args.print == 0: sys.stdout = open(os.path.join(itr_out_dir, 'iter-prints.log'), 'w') mb_data_iter = bkgdGen(data_generator=gen_train_batch_bg(mbsize=args.mbsize, \ psz=args.psz, nvar=args.nvar), \ max_prefetch=16) def main(args): model = unet() # model = DnCNN(1, num_of_layers = 8) _ = model.apply(model_init) # init model weights and bias masker = Masker(width=4, mode='zero') if torch.cuda.is_available(): if torch.cuda.device_count() > 1: model = torch.nn.DataParallel(model) model = model.to(torch_devs)
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpus os.environ[ 'TF_CPP_MIN_LOG_LEVEL'] = '3' # disable printing INFO, WARNING, and ERROR itr_out_dir = args.expName + '-itrOut' if os.path.isdir(itr_out_dir): shutil.rmtree(itr_out_dir) os.mkdir(itr_out_dir) # to save temp output # redirect print to a file if args.print == 0: sys.stdout = open('%s/%s' % (itr_out_dir, 'iter-prints.log'), 'w') # build minibatch data generator with prefetch mb_data_iter = bkgdGen(data_generator=gen_train_batch_bg( dsfn=args.dsfn, mb_size=args.mbsz, \ in_depth=args.depth, img_size=args.psz), \ max_prefetch=args.mbsz*4) generator = make_generator_model(input_shape=(None, None, args.depth), nlayers=args.lunet) discriminator = make_discriminator_model(input_shape=(args.psz, args.psz, 1)) feature_extractor_vgg = tf.keras.applications.VGG19(\ weights='vgg19_weights_notop.h5', \ include_top=False) # This method returns a helper function to compute cross entropy loss cross_entropy = tf.keras.losses.BinaryCrossentropy(from_logits=True)