Пример #1
0
            # if nothing can be loaded, generate the initial matching results and save them
            m, n = data.num_graphs, data.num_nodes
            Kt = torch.tensor(data.K).reshape(-1, n * n, n * n).cuda()
            ns_src = torch.ones(m * m).int().cuda() * n
            ns_tgt = torch.ones(m * m).int().cuda() * n
            X_continue = rrwm(Kt, n, ns_src,
                              ns_tgt).reshape(m * m, n,
                                              n).transpose(1, 2).contiguous()
            X = hungarian(X_continue, ns_src,
                          ns_tgt).reshape(m, m, n, n).cpu().detach().numpy()
            with open(init_mat_path, "wb") as f:
                pickle.dump(X, f)
        init_mat = X

        X = mgm_floyd(init_mat[:15, :15], data.K[:15, :15], 15, data.num_nodes)
        online_acc[i_iter][15] = evaluate_matching_accuracy(
            X, data.gt[:15, :15], 15, data.num_inlier)

        # apply MGM-SPFA to get better matching results
        for n_graph in range(16, data.num_graphs):
            tic = time.time()
            X_new = init_mat[:n_graph, :n_graph, :, :]
            X_new[:-1, :-1, :, :] = X
            if test_mode == "fast-spfa":
                if (n_graph == 16):
                    pc_ma = get_pairwise_socre(X_new, n_graph)
                    x = 1 - pc_ma
                    # X, pc_ma = fast_spfa(data.K[:n_graph, :n_graph, :, :], X_new, n_graph, pc_ma)
                    # cluster = DBSCAN(eps =np.min(X), min_samples= 1, metric= "precomputed" )
                    # cluster.fit(X)
                    # print(cluster.labels_)
                    # print(X)
Пример #2
0
            # if nothing can be loaded, generate the initial matching results and save them
            m, n = data.num_graphs, data.num_nodes
            Kt = torch.tensor(data.K).reshape(-1, n * n, n * n).cuda()
            ns_src = torch.ones(m * m).int().cuda() * n
            ns_tgt = torch.ones(m * m).int().cuda() * n
            X_continue = rrwm(Kt, n, ns_src,
                              ns_tgt).reshape(m * m, n,
                                              n).transpose(1, 2).contiguous()
            X = hungarian(X_continue, ns_src,
                          ns_tgt).reshape(m, m, n, n).cpu().detach().numpy()
            with open(init_mat_path, "wb") as f:
                pickle.dump(X, f)
        toc = time.time()

        # evaluate the initial matching results
        rrwm_acc = evaluate_matching_accuracy(X, data.gt, data.num_graphs,
                                              data.num_inlier)
        rrwm_time = toc - tic

        # apply MGM-Floyd to get better matching results
        tic = time.time()
        mat = mgm_floyd(X, data.K, data.num_graphs, data.num_nodes)
        toc = time.time()

        # evaluate the final matching results
        time_cost.append(toc - tic)
        acc = evaluate_matching_accuracy(mat, data.gt, data.num_graphs,
                                         data.num_inlier)
        accuracy.append(acc)

        print(
            "iter: {}/{}, init_acc: {:.4f}, floyd_acc: {:.4f}, init_time: {:.4f}, floyd_time: {:.4f}"