(dtboxes, gtboxes, thr)
| 800 | return ious |
| 801 | |
| 802 | def compute_lap(dtboxes, gtboxes, thr): |
| 803 | |
| 804 | eps = 1e-7 |
| 805 | n, k = dtboxes.shape[0], gtboxes.shape[0] |
| 806 | if k + n < 2: |
| 807 | m, n = np.array([]), np.array([]) |
| 808 | return m, n |
| 809 | |
| 810 | overlaps = compute_iou_matrix(dtboxes, gtboxes) |
| 811 | |
| 812 | if n < 2: |
| 813 | cols = np.argmax(overlaps, axis = 1) |
| 814 | rows = np.array([0]) |
| 815 | m, n = (rows, cols) if thr - overlaps[rows, cols] < eps else (np.array([]), np.array([])) |
| 816 | return m, n |
| 817 | |
| 818 | if k < 2: |
| 819 | |
| 820 | rows = np.argmax(overlaps, axis = 0) |
| 821 | cols = np.array([0]) |
| 822 | m,n = (rows, cols) if thr - overlaps[rows, cols] < eps else (np.array([]), np.array([])) |
| 823 | return m, n |
| 824 | |
| 825 | ious = overlaps * (overlaps >= thr) |
| 826 | |
| 827 | matches = minimumWeightMatching(-ious) |
| 828 | m, n = np.array([i for i, _ in matches]).astype(np.int32), np.array([i for _, i in matches]).astype(np.int32) |
| 829 | indice = np.where(overlaps[m, n] < thr)[0] |
| 830 | |
| 831 | if indice.size >= m.size: |
| 832 | m, n = np.array([]), np.array([]) |
| 833 | else: |
| 834 | index = np.array(list(set(np.arange(m.size)) - set(indice))).astype(np.int) |
| 835 | m, n = m[index], n[index] |
| 836 | |
| 837 | return m, n |
| 838 | |
| 839 | def minimumWeightMatching(costSet : np.ndarray) -> list: |
| 840 | ''' |
no test coverage detected