MCPcopy Create free account
hub / github.com/Kitware/COAT / eval_search_prw

Function eval_search_prw

eval_func.py:303–488  ·  view source on GitHub ↗

gallery_det (list of ndarray): n_det x [x1, x2, y1, y2, score] per image gallery_feat (list of ndarray): n_det x D features per image query_feat (list of ndarray): D dimensional features per query image det_thresh (float): filter out gallery detections whose scores below this ga

(
    gallery_dataset,
    query_dataset,
    gallery_dets,
    gallery_feats,
    query_box_feats,
    query_dets,
    query_feats,
    k1=30,
    k2=4,
    det_thresh=0.5,
    cbgm=False,
    gallery_size=None, # not used in PRW
    ignore_cam_id=True,
)

Source from the content-addressed store, hash-verified

301
302
303def eval_search_prw(
304 gallery_dataset,
305 query_dataset,
306 gallery_dets,
307 gallery_feats,
308 query_box_feats,
309 query_dets,
310 query_feats,
311 k1=30,
312 k2=4,
313 det_thresh=0.5,
314 cbgm=False,
315 gallery_size=None, # not used in PRW
316 ignore_cam_id=True,
317):
318 """
319 gallery_det (list of ndarray): n_det x [x1, x2, y1, y2, score] per image
320 gallery_feat (list of ndarray): n_det x D features per image
321 query_feat (list of ndarray): D dimensional features per query image
322 det_thresh (float): filter out gallery detections whose scores below this
323 gallery_size (int): -1 for using full set
324 ignore_cam_id (bool): Set to True acoording to CUHK-SYSU,
325 although it's a common practice to focus on cross-cam match only.
326 """
327 assert len(gallery_dataset) == len(gallery_dets)
328 assert len(gallery_dataset) == len(gallery_feats)
329 assert len(query_dataset) == len(query_box_feats)
330
331 annos = gallery_dataset.annotations
332 name_to_det_feat = {}
333 for anno, det, feat in zip(annos, gallery_dets, gallery_feats):
334 name = anno["img_name"]
335 scores = det[:, 4].ravel()
336 inds = np.where(scores >= det_thresh)[0]
337 if len(inds) > 0:
338 name_to_det_feat[name] = (det[inds], feat[inds])
339
340 aps = []
341 accs = []
342 topk = [1, 5, 10]
343 ret = {"image_root": gallery_dataset.img_prefix, "results": []}
344 for i in range(len(query_dataset)):
345 y_true, y_score = [], []
346 imgs, rois = [], []
347 count_gt, count_tp = 0, 0
348
349 feat_p = query_box_feats[i].ravel()
350
351 query_imname = query_dataset.annotations[i]["img_name"]
352 query_roi = query_dataset.annotations[i]["boxes"]
353 query_pid = query_dataset.annotations[i]["pids"]
354 query_cam = query_dataset.annotations[i]["cam_id"]
355
356 # Find all occurence of this query
357 gallery_imgs = []
358 for x in annos:
359 if query_pid in x["pids"] and x["img_name"] != query_imname:
360 gallery_imgs.append(x)

Callers

nothing calls this directly

Calls 3

run_kuhn_munkresFunction · 0.90
_compute_iouFunction · 0.85
printFunction · 0.85

Tested by

no test coverage detected