当前位置:网站首页>Understand test.py in gaitset

Understand test.py in gaitset

2022-07-26 12:28:00 Dance rain

''' Tab:  Concepts that must be understood before learning 
  You need to have a database first , Gaitset It has generalization ability , Gaitset It's not learning to train people's gait characteristics , But learn how to be in a group of people ( In the database ) Find the data closest to the probe .  So when in use , The database can be changed at any time without retraining . probe set  And  gallery set  The training set has probe set  And  gallery set  The test suite also has .  Refers to from gallery set out  every last gallery The extracted features , Again from probe set out  One probe The extracted features ,  The final calculation probe Characteristics and gallery set every last gallery The distance between the features of ,  Find the nearest ( The gap is the smallest ) As a result of identification   All the results are in 11 Take the average of the perspectives , And it doesn't include the same perspective .  for example , visual angle 36° The accuracy of the probe is average ! except 36° outside ! Of 10 A point of view .  ''' 
#  Import package 
from datetime import datetime import numpy as np import argparse from model.initialization import initialization from model.utils import evaluation from config import conf

#  Determine whether the string writes the correct function 
def boolean_string(s):
    if s.upper() not in {'FALSE', 'TRUE'}:
        raise ValueError('Not a valid boolean string')
    return s.upper() == 'TRUE'

#  Pass in parameters... From the command line 
parser = argparse.ArgumentParser(description='Test') parser.add_argument('--iter', default='80000', type=int, help='iter: iteration of the checkpoint to load. Default: 80000') parser.add_argument('--batch_size', default='1', type=int, help='batch_size: batch size for parallel test. Default: 1') parser.add_argument('--cache', default=False, type=boolean_string, help='cache: if set as TRUE all the test data will be loaded at once' ' before the transforming start. Default: FALSE') opt = parser.parse_args()

# Exclude identical-view cases
#  Subtract the diagonal data , That is, data from the same perspective ,each_angle=True Means only take NM,BG,CL Three respective 11/10 The average of angles 
def de_diag(acc, each_angle=False): result = np.sum(acc - np.diag(np.diag(acc)), 1) / 10.0 if not each_angle: result = np.mean(result) return result

#  Model initialization + Data initialization 
m = initialization(conf, test=opt.cache)[0] # load model checkpoint of iteration opt.iter print('Loading the model of iteration %d...' % opt.iter) m.load(opt.iter) print('Transforming...') time = datetime.now() test = m.transform('test', opt.batch_size) 
#  Evaluate the accuracy of data set acquisition  #  among acc Is a four-dimensional array (p, v1, v2, accuracy)
# p==1 Express NM p==2 Express BG p==3 Express CL
print('Evaluating...') acc = evaluation(test, conf['data']) print('Evaluation complete. Cost:', datetime.now() - time)

# Print rank-1 accuracy of the best model
#  translate :
#   rank-1  Accuracy of five of the five categories  rank-5  The accuracy of one of the five categories 
# e.g.
# ===Rank-1 (Include identical-view cases)===
#  translate :
#    Don't rule out the same perspective 
# NM: 95.405,     BG: 88.284,     CL: 72.041
for i in range(1): print('===Rank-%d (Include identical-view cases)===' % (i + 1)) print('NM: %.3f,\tBG: %.3f,\tCL: %.3f' % ( np.mean(acc[0, :, :, i]), np.mean(acc[1, :, :, i]), np.mean(acc[2, :, :, i])))

# Print rank-1 accuracy of the best model,excluding identical-view cases
# e.g.
# ===Rank-1 (Exclude identical-view cases)===
#  translate :
#  Exclude the same perspective 
# NM: 94.964,     BG: 87.239,     CL: 70.355
for i in range(1): print('===Rank-%d (Exclude identical-view cases)===' % (i + 1)) print('NM: %.3f,\tBG: %.3f,\tCL: %.3f' % ( de_diag(acc[0, :, :, i]), de_diag(acc[1, :, :, i]), de_diag(acc[2, :, :, i])))

# Print rank-1 accuracy of the best model (Each Angle)
# e.g.
# ===Rank-1 of each angle (Exclude identical-view cases)===
#  translate :
#  Exclude the same perspective 
# VE: [00.00 18.00 36.00 54.00 72.00 90.00 108.0 126.0 144.0 162.0 180.0]
# NM: [90.80 97.90 99.40 96.90 93.60 91.70 95.00 97.80 98.90 96.80 85.80]
# @ -------------------------- NM Split line  ------------------------------ @ #
# BG: [86.30 91.30 93.30 89.90 85.50 80.50 84.50 90.40 92.30 92.12 82.20]
# CL: [69.10 78.90 79.00 76.80 69.20 67.80 70.30 73.40 74.60 70.70 58.30]

# np.set_printoptions()—— Control output mode 
# precision: Control the number of decimal points of the output , The default is 8
np.set_printoptions(precision=2, floatmode='fixed') for i in range(1): print('===Rank-%d of each angle (Exclude identical-view cases)===' % (i + 1)) print("View:", end='') for view in range(0, 181, 18): if view == 0: print(str(view)+'0.00', end=' ') elif 100 < view < 180: print(str(view) + '.0', end=' ') elif view == 180: print(str(view) + '.00', end='') else: print(str(view) + '.00', end=' ') print('') print('NM:', de_diag(acc[0, :, :, i], True)) print('BG:', de_diag(acc[1, :, :, i], True)) print('CL:', de_diag(acc[2, :, :, i], True))
原网站

版权声明
本文为[Dance rain]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207261219577881.html