Ejemplo n.º 1
0
def predict_eval(target, predict_path):
    if target == 'market' or target == 'market-r':
        market_result_eval(predict_path)
    elif target == 'markets1' or target == 'markets1-r':
        market_result_eval(predict_path, TEST='/home/cwh/coding/markets1/test', QUERY='/home/cwh/coding/markets1/probe')
    elif 'grid' in target:
        grid_result_eval(predict_path)
Ejemplo n.º 2
0
def predict_eval(target, predict_path):
    if target == 'market' or target == 'market-r':
        market_result_eval(predict_path,
                           TEST = '/home/cwh/coding/Market-1501/test', QUERY = '/home/cwh/coding/Market-1501/probe')
    elif 'grid' in target:
        grid_result_eval(predict_path)
    elif 'duke' in target:
        market_result_eval(predict_path, log_path='duke_eval.log', TEST = '/home/cwh/coding/DukeMTMC-reID/test', QUERY = '/home/cwh/coding/DukeMTMC-reID/probe')
Ejemplo n.º 3
0
    net = Model(inputs=[net.get_layer('resnet50').get_input_at(0)],
                outputs=[net.get_layer('resnet50').get_output_at(0)])
    # net = Model(inputs=[net.input], outputs=[net.get_layer('avg_pool').output])
    test_f, test_info = extract_feature(gallery_path, net)
    query_f, query_info = extract_feature(probe_path, net)
    result, result_argsort = sort_similarity(query_f, test_f)
    for i in range(len(result)):
        result[i] = result[i][result_argsort[i]]
    result = np.array(result)
    safe_remove(pid_path)
    safe_remove(score_path)
    np.savetxt(pid_path, result_argsort, fmt='%d')
    np.savetxt(score_path, result, fmt='%.4f')


if __name__ == '__main__':
    source = 'market'
    target = 'market'
    for i in range(10):
        net = load_model('../pretrain/' + source +
                         '_multi_sd_pretrain_%d.h5' % i)
        target_path = '/home/cwh/coding/Market-1501'
        probe_path = target_path + '/probe'
        gallery_path = target_path + '/test'
        train_path = target_path + '/train'
        pid_path = 'ret_train_pid.txt'
        score_path = 'ret_train_score.txt'
        # train_predict(net, train_path, pid_path, score_path)
        test_predict(net, probe_path, gallery_path, pid_path, score_path)
        market_result_eval(pid_path, 'market_eval.txt', gallery_path,
                           probe_path)
Ejemplo n.º 4
0
def predict_eval(target, predict_path):
    if target == 'market' or target == 'market-r':
        market_result_eval(predict_path,
                           TEST='/home/cwh/coding/Market-1501/test',
                           QUERY='/home/cwh/coding/Market-1501/probe')
    elif 'grid' in target:
        grid_result_eval(predict_path)
    elif 'duke' == target:
        market_result_eval(predict_path,
                           log_path='duke_eval.log',
                           TEST='/home/cwh/coding/DukeMTMC-reID/test',
                           QUERY='/home/cwh/coding/DukeMTMC-reID/probe')
    elif 'dukehead' == target:
        market_result_eval(predict_path,
                           log_path='duke_head_eval.log',
                           TEST='/home/cwh/coding/dukehead/test',
                           QUERY='/home/cwh/coding/dukehead/probe')
    elif 'duketail' == target:
        market_result_eval(predict_path,
                           log_path='duke_tail_eval.log',
                           TEST='/home/cwh/coding/duketail/test',
                           QUERY='/home/cwh/coding/duketail/probe')
    elif 'duketqtail' == target:
        market_result_eval(predict_path,
                           log_path='duke_tqtail_eval.log',
                           TEST='/home/cwh/coding/duketqtail/test',
                           QUERY='/home/cwh/coding/duketqtail/probe')
    elif 'dukequerytail' == target:
        market_result_eval(predict_path,
                           log_path='duke_querytail_eval.log',
                           TEST='/home/cwh/coding/dukequerytail/test',
                           QUERY='/home/cwh/coding/dukequerytail/probe')
Ejemplo n.º 5
0

def grid_eval(source, transform_dir):
    target = 'grid'
    for i in range(10):
        test_pair_predict(source + '_pair_pretrain.h5',
                          transform_dir + 'cross%d' % i + '/probe',
                          transform_dir + 'cross%d' % i + '/test',
                          source + '_' + target + '_pid.log',
                          source + '_' + target + '_score.log')
        grid_result_eval(source + '_' + target + '_pid.log', 'gan.log')


def market_eval(source, transform_dir):
    target = 'market'
    test_pair_predict(source + '_model.h5', transform_dir + '/query',
                      transform_dir + '/bounding_box_test',
                      source + '_' + target + '_pid.log',
                      source + '_' + target + '_score.log')


if __name__ == '__main__':
    os.environ["CUDA_VISIBLE_DEVICES"] = "1"
    market_eval('market', '../dataset/Market-1501-v15.09.15')
    market_result_eval(
        'market_market_pid.log',
        TEST='../dataset/Market-1501-v15.09.15/bounding_box_test',
        QUERY='../dataset/Market-1501-v15.09.15/query')
    # grid_eval('market', '/home/person/grid_train_probe_gallery/cross0')
    #grid_result_eval('/home/person/TrackViz/data/market_grid-cv0-test/cross_filter_pid.log')
Ejemplo n.º 6
0
        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')
Ejemplo n.º 7
0
if __name__ == '__main__':
    # train_pair_predict('market_pair_pretrain.h5', '/home/cwh/coding/grid_train_probe_gallery/cross0/train', 'market_grid_pid.txt', 'market_grid_score.txt')
    # grid_test_base_eval('../baseline/0.ckpt', 'grid_cross0_single')
    # cross0: [0.072, 0.144, 0.184, 0.232, 0.408]
    # cross0_gan: [0.136, 0.344, 0.416, 0.544, 0.648]
    # grid_test_pair_eval('../transfer/pair_pretrain.h5', 'grid_cross0_pair_pretrain')
    # [0.088, 0.16, 0.2, 0.296, 0.456]
    # grid_test_pair_eval('../transfer/pair_transfer.h5', 'grid_cross0_transfer')
    # [0.192, 0.312, 0.376, 0.496, 0.624] epoch7
    # [0.192, 0.312, 0.392, 0.48, 0.648] st epoch3
    # grid_test_rank_eval('../transfer/rank_transfer.h5', 'grid_cross0_rank_transfer')
    # [0.184, 0.304, 0.344, 0.456, 0.656]
    # test_pair_predict('grid_softmax_pretrain.h5', '/home/cwh/coding/Market-1501/probe', '/home/cwh/coding/Market-1501/test', 'market_market_pid_test.txt', 'market_market_score_test.txt')
    # test_pair_predict('market_softmax_pretrain.h5', '/home/wxt/reid_data-gan/cross0_gan/probe', '/home/wxt/reid_data-gan/cross0_gan/test', 'market_market_pid_test_gan.txt', 'market_market_score_test_gan.txt')
    # test_pair_predict('market_pair_pretrain.h5', '/home/cwh/coding/grid_train_probe_gallery/cross0/probe', '/home/cwh/coding/grid_train_probe_gallery/cross0/test', 'market_market_pid_test_softmax.txt', 'market_market_score_test_softmax.txt')
    # grid_result_eval('market_market_pid_test_softmax.txt', './gan.log')
    # [0.104, 0.176, 0.264, 0.312, 0.416]
    # grid_eval('market', '/home/wxt/ReidGAN/transformgrid2marketstyle')
    # market_eval('grid', '/home/wxt/ReidGAN/market2grid_style')
    market_eval('market', '/home/cwh/coding/Market-1501')
    market_result_eval('market_market_pid.log')
    # market_result_eval('/home/cwh/coding/TrackViz/data/market_market-test/cross_filter_pid.log')
    # test_rank_predict('../transfer/rank_transfer_test.h5',
    #                   '/home/cwh/coding/Market-1501/probe', '/home/cwh/coding/Market-1501/test',
    #                   'rank_pid.log', 'rank_ac.log')
    # market_result_eval('rank_pid.log')
    # grid_result_eval('/home/cwh/coding/TrackViz/data/market_grid-cv0-test/cross_filter_pid.log')
    # market_result_eval('/home/cwh/coding/TrackViz/data/market_market-test/cross_filter_pid.log')