def vision_predict(source, target, train_pid_path, train_score_path, test_pid_path, test_score_path): source_model_path, target_dataset_path = get_source_target_info(source, target) target_probe_path = target_dataset_path + '/probe' target_train_path = target_dataset_path + '/train' target_gallery_path = target_dataset_path + '/test' train_pair_predict(source_model_path, target_train_path, train_pid_path, train_score_path) test_pair_predict(source_model_path, target_probe_path, target_gallery_path, test_pid_path, test_score_path) predict_eval(target, test_pid_path)
batch_size=batch_size ) def pair_transfer_2grid(): DATASET = '/home/cwh/coding/grid_train_probe_gallery/cross0' LIST = os.path.join(DATASET, 'pretrain/test_track.txt') TRAIN = os.path.join(DATASET, 'pretrain') train_images = reid_img_prepare(LIST, TRAIN) batch_size = 64 # similar_persons = np.genfromtxt('../pretrain/grid_cross0/train_renew_pid.log', delimiter=' ') # similar_matrix = np.genfromtxt('../pretrain/grid_cross0/train_renew_ac.log', delimiter=' ') similar_persons = np.genfromtxt('../pretrain/grid_cross0/cross_filter_pid.log', delimiter=' ') - 1 similar_matrix = np.genfromtxt('../pretrain/grid_cross0/cross_filter_score.log', delimiter=' ') pair_transfer( pair_generator_by_rank_list(train_images, batch_size, similar_persons, similar_matrix, train=True), pair_generator_by_rank_list(train_images, batch_size, similar_persons, similar_matrix, train=False), '../pretrain/pair_pretrain.h5', batch_size=batch_size ) if __name__ == '__main__': pair_transfer_2grid() test_pair_predict('../transfer/pair_transfer.h5', '/home/cwh/coding/grid_train_probe_gallery/cross0/probe', '/home/cwh/coding/grid_train_probe_gallery/cross0/gallery', 'pid_path', 'score_path' )
pair_generator_by_rank_list(train_images, batch_size, similar_persons, similar_matrix, train=False), target, batch_size=batch_size, num_classes=class_count ) if __name__ == '__main__': # sources = ['cuhk_grid_viper_mix'] sources = ['cuhk'] target = 'market' pair_model('../pretrain/cuhk_pair_pretrain.h5', 751) for source in sources: pair_pretrain_on_dataset(source, target) transform_dir = '/home/cwh/coding/Market-1501' safe_remove('pair_transfer_pid.log') test_pair_predict('market_pair_pretrain.h5', transform_dir + '/probe', transform_dir + '/test', 'pair_transfer_pid.log', 'pair_transfer_score.log') market_result_eval('pair_transfer_pid.log', TEST='/home/cwh/coding/Market-1501/test', QUERY='/home/cwh/coding/Market-1501/probe') # sources = ['grid-cv-%d' % i for i in range(10)] # for source in sources: # softmax_pretrain_on_dataset(source, # project_path='/home/cwh/coding/rank-reid', # dataset_parent='/home/cwh/coding') # pair_pretrain_on_dataset(source, # project_path='/home/cwh/coding/rank-reid', # dataset_parent='/home/cwh/coding')