MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / test_extract_detections

Function test_extract_detections

tests/test_predict_multianimal.py:26–49  ·  view source on GitHub ↗
(model_outputs, ground_truth_detections)

Source from the content-addressed store, hash-verified

24
25
26def test_extract_detections(model_outputs, ground_truth_detections):
27 scmaps, locrefs, _ = model_outputs
28 inds_gt = []
29 for i in range(scmaps.shape[3]):
30 scmap = scmaps[0, ..., i]
31 peaks = predict_multianimal.find_local_maxima(scmap, RADIUS, THRESHOLD)
32 inds_gt.append(np.c_[peaks, np.ones(len(peaks)).reshape((-1, 1)) * i])
33 inds_gt = np.concatenate(inds_gt).astype(int)
34 pos_gt = np.concatenate(ground_truth_detections[0]["coordinates"][0])
35 prob_gt = np.concatenate(ground_truth_detections[0]["confidence"])
36 inds = predict_multianimal.find_local_peak_indices_maxpool_nms(
37 scmaps,
38 RADIUS,
39 THRESHOLD,
40 )
41 with tf.compat.v1.Session() as sess:
42 inds = sess.run(inds)
43 pos = predict_multianimal.calc_peak_locations(locrefs, inds, STRIDE)
44 s, r, c, b = inds.T
45 prob = scmaps[s, r, c, b].reshape((-1, 1))
46 idx = np.argsort(inds[:, -1], kind="mergesort")
47 np.testing.assert_equal(inds[idx, 1:], inds_gt)
48 np.testing.assert_almost_equal(pos[idx], pos_gt, decimal=3)
49 np.testing.assert_almost_equal(prob[idx], prob_gt, decimal=5)
50
51
52def test_association_costs(model_outputs, ground_truth_detections):

Callers

nothing calls this directly

Calls 3

calc_peak_locationsMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected