MCPcopy Create free account
hub / github.com/Alioth2000/Hoss-ReID / do_inference

Function do_inference

processor/processor.py:215–247  ·  view source on GitHub ↗
(cfg, model, val_loader, num_query)

Source from the content-addressed store, hash-verified

213
214
215def do_inference(cfg, model, val_loader, num_query):
216 device = "cuda"
217 logger = logging.getLogger("transreid.test")
218 logger.info("Enter inferencing")
219
220 evaluator = R1_mAP_eval(num_query, max_rank=50, feat_norm=cfg.TEST.FEAT_NORM)
221
222 evaluator.reset()
223
224 if device:
225 if torch.cuda.device_count() > 1:
226 print("Using {} GPUs for inference".format(torch.cuda.device_count()))
227 model = nn.DataParallel(model)
228 model.to(device)
229
230 model.eval()
231 img_path_list = []
232
233 for n_iter, (img, pid, camid, camids, target_view, imgpath, img_wh) in enumerate(val_loader):
234 with torch.no_grad():
235 img = img.to(device)
236 camids = camids.to(device)
237 img_wh = img_wh.to(device)
238 feat = model(img, cam_label=camids, img_wh=img_wh)
239 evaluator.update((feat, pid, camid))
240 img_path_list.extend(imgpath)
241
242 cmc, mAP, _, _, _, _, _ = evaluator.compute()
243 logger.info("Validation Results ")
244 logger.info("mAP: {:.1%}".format(mAP))
245 for r in [1, 5, 10]:
246 logger.info("CMC curve, Rank-{:<3}:{:.1%}".format(r, cmc[r - 1]))
247 return cmc[0], cmc[4]

Callers 1

test.pyFile · 0.90

Calls 4

resetMethod · 0.95
updateMethod · 0.95
computeMethod · 0.95
R1_mAP_evalClass · 0.90

Tested by

no test coverage detected