(model_outputs, ground_truth_detections)
| 24 | |
| 25 | |
| 26 | def 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 | |
| 52 | def test_association_costs(model_outputs, ground_truth_detections): |
nothing calls this directly
no test coverage detected