arg.save_dir = "%s/outs/%s"%(os.getcwd(), arg.save_dir) if os.path.exists(arg.save_dir) is False: os.mkdir(arg.save_dir) logger = Logger(arg.save_dir) copyreg.pickle(torch.dtype, pickle_torch_dtype) os.environ["CUDA_VISIBLE_DEVICES"] = arg.gpus torch_device = torch.device("cuda") preprocess = preprocess.get_preprocess(arg.augment) train_loader = nucleusloader(f_path_train, arg.batch_size, transform=preprocess, cpus=arg.cpus, shuffle=True, drop_last=True) valid_loader = nucleusloader3(f_path_valid, batch_size=1, transform=None, cpus=arg.cpus, shuffle=False, drop_last=True) if arg.model == "fusion": net = Fusionnet(arg.in_channel, arg.out_channel, arg.ngf, arg.clamp) elif arg.model == "unet": net = Unet3D(feature_scale=arg.feature_scale) elif arg.model == "unet_gh": ## "nets_1004_unet_glob_absloss_FRE_pw10_erode2_feat1_trans30" #net = Unet3D_glob2(feature_scale=arg.feature_scale, trans_feature=64) #net = Unet3D_glob(feature_scale=arg.feature_scale, trans_feature=64)
erode=3, backzero=backzero) model = CNNTrainer(arg, net, torch_device, recon_loss=recon_loss, val_loss=val_loss, logger=logger) #model.load(filename="epoch[0402]_losssum[0.016887].pth.tar") model.load(filename="epoch[0493]_losssum[0.015393].pth.tar") ######phase 1###### test_loader = nucleusloader(f_path_test + '/dataset1/exp0_fullsequence', batch_size=1, transform=None, cpus=arg.cpus, shuffle=False, drop_last=True) model.test(test_loader, savedir='dataset1') ######phase 2###### #listdir=os.listdir(f_path_test+'/dataset2') #for ld in listdir: # if ld.find('2018')!=0: # test_loader = nucleusloader(f_path_test+'/dataset2/'+ld, batch_size=1, transform=None, # cpus=arg.cpus, shuffle=False, # drop_last=True) # model.test(test_loader,savedir='dataset2_'+ld) # for ld in listdir: