utils package

Submodules

utils.adj_matrix module

utils.adj_matrix.Norm_F(feature, norm_flag)
Args:

feature: features to be normalized, (b,c,1,n) norm_flag: normalization flag: constant, l1norm, l2norm

Returns:

normalized feature in the third dimension size: (b,c,1,n)

utils.adj_matrix.build_idx(num)
Args:

num: number of graph nodes

Returns:

indices of each nodes

utils.adj_matrix.buildnear(i, j, len, edge)
utils.adj_matrix.gen_adj(block_width, batch)
Args:

block_width: feature size width/height used for spatial GCN batch: batchsize

Returns:

adj matrices

utils.adj_matrix.gen_adj2(num_block)
utils.adj_matrix.gen_adj_coo(block_width, batch)

generate adjacent matrices by COO form

utils.adj_matrix.gen_adj_nearst(num_block, part_features)

enable nearst connections for the graph embedding Args:

num_block: part_features:

Returns:

utils.adj_matrix.gen_adj_sim(num_block, part_features1, part_features2, enable_mask=False)

default similarity function, calculate similarity between two input features

enable_mask: encourage sparse connections when similarities higher than the threshold

Args:

num_block: abandoned feature part_features1: vector1, size = b,c,n1 part_features2: vector2, size = b,c,n2 enable_mask: True/ False

Returns:

similarity matrices: size: n1 * n2

utils.adj_matrix.gen_adj_sim_old(num_block, part_features)
utils.adj_matrix.gen_adj_topk(num_block, part_features)
utils.adj_matrix.get_sim_cross(edge)

handcrafted similarity matrices

Args:

edge:

Returns:

utils.adj_matrix.get_sim_cross2(edge)

handcrafted similarity matrices

utils.adj_matrix.get_sim_local(edge1, edge2)

get local connections Args:

edge1: edge2:

Returns:

utils.adj_matrix.mul_dis(feature1, feature2)

matmul similarity function

utils.adj_matrix.sim_dis(feature1, feature2)

cosine simlarity function

utils.logger module

utils.logger.label2colormap(label)
utils.logger.setup_logger(name, save_dir)

utils.meter module

class utils.meter.AverageMeter

Bases: object

Computes and stores the average and current value

reset()
update(val, n=1)

utils.metrics module

class utils.metrics.R1_mAP(num_query, max_rank=50, feat_norm=True, method='euclidean', reranking=False)

Bases: object

compute()
compute_acc()
reset()
update(output)
utils.metrics.cosine_similarity(qf, gf)
utils.metrics.euclidean_distance(qf, gf)
utils.metrics.eval_func(distmat, q_pids, g_pids, max_rank=50)

Evaluation with market1501 metric Key: for each query identity, its gallery images from the same camera view are discarded.

utils.reranking module

Created on Fri, 25 May 2018 20:29:09

@author: luohao

utils.reranking.re_ranking(probFea, galFea, k1, k2, lambda_value, local_distmat=None, only_local=False)

Module contents