示例#1
0
class_name = ["Car", "Motorbike", "Face", "Winebottle", "Duck"]

# set parameters for offline multi-graph matching test
test_iter = 1  # test iteration for each class, please set it less than 5 or new data will be generated

# number of graphs, inliers and outliers only affect the generated data (when test_iter is larger than 5),
# these parameters will not be used when the data is loaded from TestPrepare.
test_num_graph = 8  # number of graphs in each test
test_num_cluster = 2  # number of clusters
test_num_graph_cluster = 4  # number of graphs in each dataset(cluster)
test_num_inlier = 10  # number of inliers in each graph
test_num_outlier = 2  # number of outliers in each graph

assert test_num_graph == test_num_cluster * test_num_graph_cluster

rrwm = RRWM()
cfg = CFG()

print(
    "Test begin: test online multi-graph matching on {}".format(dataset_name))
time_list, cp_list, ri_list, ca_list = [], [], [], []
for i_iter in range(test_iter):
    # prepare affinity matrix data for graph matching

    # set the path for loading data
    test_data_folder = "cluster_data_{}*{}".format(test_num_cluster,
                                                   test_num_graph_cluster)
    test_data_folder_path = "data" + "/" + "TestPrepare" + "/" + test_data_folder
    print(test_data_folder_path)
    if not os.path.exists(test_data_folder_path):
        os.mkdir(test_data_folder_path)
示例#2
0
import os
import time
import torch

from data.data_loader_multigraph import GMDataset, get_dataloader
from src.cao import CAO
from src.rrwm import RRWM
from src.mgm_floyd import Floyd
from utils.build_affinity import get_K
from utils.config import cfg
from utils.edge2adj import edge2adj
from utils.eval_metric import cal_accuracy, cal_affinity, cal_consistency
from utils.hungarian import hungarian
from utils.utils import update_params_from_cmdline, lexlist2tensor

rrwm_solver = RRWM()
cao_solver = CAO()
floyd_solver = Floyd()


def eval_test(mat, gt_mat, affinity, m, n):
    acc = cal_accuracy(mat, gt_mat, n)
    src = cal_affinity(mat, gt_mat, affinity, m, n)
    con = cal_consistency(mat, gt_mat, m, n)
    return acc, src, con


def update(acc, aff, con, tim, mat_accuracy, mat_affinity, mat_consistency, mat_time, i_m, i_test):
    mat_accuracy[i_m][i_test] = acc
    mat_affinity[i_m][i_test] = aff
    mat_consistency[i_m][i_test] = con