Exemple #1
0
train_dataset = AmbiLocalFeatDataset(
    iccv_res_dir=iccv_res_dir,
    image_dir=cambridge_img_dir,
    lmdb_paths=lmdb_img_cache,
    dataset_list=dataset_list,
    downsample_scale=0.5,
    sampling_num=30,
    sample_res_cache='/mnt/Exp_5/AmbiguousData_pg/temp_cache.bin',
    sub_graph_nodes=24)

# set train parameters
train_params = TrainParameters()
train_params.MAX_EPOCHS = 20
train_params.START_LR = 1.0e-4
train_params.DEV_IDS = [0, 1]
train_params.LOADER_BATCH_SIZE = 1
train_params.LOADER_NUM_THREADS = 0
train_params.VALID_STEPS = 5000
train_params.MAX_VALID_BATCHES_NUM = 20
train_params.CHECKPOINT_STEPS = 6000
train_params.VERBOSE_MODE = True
train_params.NAME_TAG = 'test_gat_cluster'

box = LocalGlobalGATTrainBox(train_params=train_params,
                             ckpt_path_dict=checkpoint_dict)

train_loader = dataloader.DataLoader(train_dataset,
                                     batch_size=1,
                                     shuffle=False,
                                     pin_memory=True,
filter_edges_by_weight = False                  # filter edges by weight, use only for 
                                                # large-scale graphs if GPU memory is limited

selected_topk = 50                              # select top-k for MSP

max_init_itr = 10                               # max optimization iterations for initial pose 
                                                # (forward, backward MSP using Adam)

max_final_itr = 10                              # max optimization iterations for final pose 
                                                # (forward, backward MSP + FineNet using Adam)


""" Load pre-trained model ---------------------------------------------------------------------------------------------
"""
train_params = TrainParameters()
train_params.DEV_IDS = [args.gpu_id, args.gpu_id]
train_params.VERBOSE_MODE = False
box = LocalGlobalVLADTrainBox(train_params=train_params, top_k=20, ckpt_path_dict={
    'vlad': './models/netvlad_vgg16.tar',
    'ckpt': "./models/yfcc_80nodes.pth.tar"
})
box._prepare_eval()

""" Dataset ------------------------------------------------------------------------------------------------------------
"""
test_dataset_json = args.dataset

test_dataset = make_dataset(test_dataset_json, load_img=False, load_node_edge_feat=True)
dataloader = DataLoader(test_dataset, batch_size=1, num_workers=0, shuffle=True)