MCPcopy
hub / github.com/thuml/Transfer-Learning-Library / validate

Function validate

tllib/utils/metric/reid.py:259–274  ·  view source on GitHub ↗
(val_loader, model, query, gallery, device, criterion='cosine', cmc_flag=False, rerank=False)

Source from the content-addressed store, hash-verified

257
258
259def validate(val_loader, model, query, gallery, device, criterion='cosine', cmc_flag=False, rerank=False):
260 assert criterion in ['cosine', 'euclidean']
261 # when criterion == 'cosine', normalize feature of single image into unit norm
262 normalize = (criterion == 'cosine')
263
264 feature_dict = extract_reid_feature(val_loader, model, device, normalize)
265 dist_mat = pairwise_distance(feature_dict, query, gallery)
266 results = evaluate_all(dist_mat, query=query, gallery=gallery, cmc_flag=cmc_flag)
267 if not rerank:
268 return results
269 # apply person re-ranking
270 print('Applying person re-ranking')
271 dist_mat_query = pairwise_distance(feature_dict, query, query)
272 dist_mat_gallery = pairwise_distance(feature_dict, gallery, gallery)
273 dist_mat = re_ranking(dist_mat, dist_mat_query, dist_mat_gallery)
274 return evaluate_all(dist_mat, query=query, gallery=gallery, cmc_flag=cmc_flag)
275
276
277# location parameters for visualization

Callers 5

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 4

extract_reid_featureFunction · 0.85
pairwise_distanceFunction · 0.85
evaluate_allFunction · 0.85
re_rankingFunction · 0.85

Tested by

no test coverage detected