Exemplo n.º 1
0
                  f'Experiment_Code: app_02;\n'

    os.environ['CUDA_VISIBLE_DEVICES'] = '1,2,3'

    device = 'cuda'
    torch.backends.cudnn.benchmark = True

    transform = transforms.Compose([
        transforms.Resize(args.size),
        transforms.CenterCrop(args.size),
        transforms.ToTensor(),
        transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
    ])

    loader, _, _ = iPERLoader(data_root=args.path,
                              batch=128,
                              transform=transform).data_load()

    model = VQVAE().to(device)
    model = nn.DataParallel(model).cuda()

    optimizer = optim.Adam(model.parameters(), lr=args.lr)
    scheduler = None
    if args.sched == 'cycle':
        scheduler = CycleScheduler(optimizer,
                                   args.lr,
                                   n_iter=len(loader) * args.epoch,
                                   momentum=None)

    print('Loading Model...', end='')
    model.load_state_dict(
Exemplo n.º 2
0
        win='board')

    os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu
    device = 'cuda'
    torch.backends.cudnn.benchmark = True

    transform = transforms.Compose([
        transforms.Resize(args.size),
        transforms.CenterCrop(args.size),
        transforms.ToTensor(),
        transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
    ])
    # TODO use a little set for sanity check
    # _, _, loader = iPERLoader(data_root=args.path, batch=args.batch_size, transform=transform).data_load()
    _, loader, _ = iPERLoader(data_root=args.path,
                              batch=args.batch_size,
                              transform=transform).data_load()

    # model for image
    model_img = VQVAE().to(device)
    model_img = nn.DataParallel(model_img).cuda()
    if is_load_model_img is True:
        print('Loading model_img ...', end='')
        model_img.load_state_dict(torch.load(args.model_img_path))
        model_img.eval()
        print('Done')
    else:
        print('model_img Initialized.')
    # optimizer_img = optim.Adam(model_img.parameters(), lr=args.lr)

    # model for condition
Exemplo n.º 3
0
        f'Experiment_Code: {EXPERIMENT_CODE};\n',
        win='board')

    os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu
    device = 'cuda'

    transform = transforms.Compose([
        transforms.Resize(args.size),
        transforms.CenterCrop(args.size),
        transforms.ToTensor(),
        transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
    ])
    # TODOn use a little set for sanity check
    # _, _, loader = iPERLoader(data_root=args.path, batch=BATCH_SIZE, transform=transform).data_load()
    loader, _, _ = iPERLoader(data_root=args.path,
                              batch=BATCH_SIZE,
                              transform=transform).data_load()

    # model
    model = VQVAE().to(device)
    model = nn.DataParallel(model).to(device)
    optimizer = optim.Adam(model.parameters(), lr=args.lr)
    scheduler = None
    if args.sched == 'cycle':
        scheduler = CycleScheduler(optimizer,
                                   args.lr,
                                   n_iter=len(loader) * args.epoch,
                                   momentum=None)

    print('Loading Model...', end='')
    model.load_state_dict(