gpu_list = str(GPU) else: multi_gpus = True for i, gpu_id in enumerate(GPU): gpu_list += str(gpu_id) if i != len(GPU) - 1: gpu_list += ',' os.environ['CUDA_VISIBLE_DEVICES'] = gpu_list # other init start_epoch = 1 save_dir = os.path.join(SAVE_DIR, MODEL_PRE + 'v2_' + datetime.now().strftime('%Y%m%d_%H%M%S')) if os.path.exists(save_dir): raise NameError('model dir exists!') os.makedirs(save_dir) logging = init_log(save_dir) _print = logging.info # define trainloader and testloader trainset = CASIA_Face(root=CASIA_DATA_DIR) trainloader = torch.utils.data.DataLoader(trainset, batch_size=BATCH_SIZE, shuffle=True, num_workers=8, drop_last=False) # nl: left_image_path # nr: right_image_path nl, nr, folds, flags = parseList(root=LFW_DATA_DIR) testdataset = LFW(nl, nr) testloader = torch.utils.data.DataLoader(testdataset, batch_size=32, shuffle=False, num_workers=8, drop_last=False)
else: multi_gpus = True for i, gpu_id in enumerate(GPU): gpu_list += str(gpu_id) if i != len(GPU) - 1: gpu_list += ',' os.environ['CUDA_VISIBLE_DEVICES'] = gpu_list # other init start_epoch = 1 save_dir = os.path.join( SAVE_DIR, MODEL_PRE + 'v2_' + datetime.now().strftime('%Y%m%d_%H%M%S')) if os.path.exists(save_dir): raise NameError('model dir exists!') os.makedirs(save_dir) logging = init_log(save_dir) _print = logging.info # define trainloader and testloader trainset = CASIA_Face(root=CASIA_DATA_DIR) trainloader = torch.utils.data.DataLoader(trainset, batch_size=BATCH_SIZE, shuffle=True, num_workers=8, drop_last=False) # nl: left_image_path # nr: right_image_path nl, nr, folds, flags = parseList(root=LFW_DATA_DIR) testdataset = LFW(nl, nr) testloader = torch.utils.data.DataLoader(testdataset,
parser.add_option("-e", "--trainingEpochs", action="store", type="int", dest="trainingEpochs", default=10, help="Number of training epochs") parser.add_option("-b", "--batchSize", action="store", type="int", dest="batchSize", default=16, help="Batch Size") #Input Reader Params parser.add_option("--ft", action="store_true", dest="ft", default=False, help="Use pre-trained models from DermNet") parser.add_option("--cutout", action="store_true", dest="cutout", default=False, help="applying cutout") parser.add_option("--focal", action="store_true", dest="focal", default=False, help="applying focal loss") # Parse command line options (options, args) = parser.parse_args() print(options) start_epoch = 1 if os.path.exists(options.save_dir): raise NameError('model dir exists!') os.makedirs(options.save_dir) logging = init_log(options.save_dir) _print = logging.info # read dataset trainset = dataset.CUB(root_dir='core/2016train', is_train=True) trainloader = torch.utils.data.DataLoader(trainset, batch_size=options.batchSize, shuffle=True, num_workers=0, drop_last=False) testset = dataset.CUB(root_dir='core/2016test', is_train=False) testloader = torch.utils.data.DataLoader(testset, batch_size=options.batchSize, shuffle=False, num_workers=0, drop_last=False) # define model net = model.attention_net(topN=PROPOSAL_NUM) if resume: ckpt = torch.load(resume) net.load_state_dict(ckpt['net_state_dict']) start_epoch = ckpt['epoch'] + 1