Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the dependency of lap #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lap
from scipy.optimize import linear_sum_assignment
import numpy as np
import scipy
from scipy.spatial.distance import cdist
Expand Down Expand Up @@ -39,7 +39,8 @@ def linear_assignment(cost_matrix, thresh):
if cost_matrix.size == 0:
return np.empty((0, 2), dtype=int), tuple(range(cost_matrix.shape[0])), tuple(range(cost_matrix.shape[1]))
matches, unmatched_a, unmatched_b = [], [], []
cost, x, y = lap.lapjv(cost_matrix, extend_cost=True, cost_limit=thresh)
x, y = linear_sum_assignment(cost_matrix)
cost = cost_matrix[x, y].sum()
for ix, mx in enumerate(x):
if mx >= 0:
matches.append([ix, mx])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import motmetrics as mm
import numpy as np

mm.lap.default_solver = "lap"
mm.lap.default_solver = "scipy.optimize"


class Evaluator(object):
Expand All @@ -22,7 +22,7 @@ def eval_frame(self, gt_tlwhs, gt_ids, ignore_tlwhs, trk_tlwhs, trk_ids, rtn_eve
keep = np.ones(len(trk_tlwhs), dtype=bool)
iou_distance = mm.distances.iou_matrix(ignore_tlwhs, trk_tlwhs, max_iou=0.5)
if len(iou_distance) > 0:
match_is, match_js = mm.lap.linear_sum_assignment(iou_distance)
match_is, match_js = linear_sum_assignment(iou_distance)
match_is, match_js = (np.asarray(a, dtype=int) for a in [match_is, match_js])
match_ious = iou_distance[match_is, match_js]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def nms(np.ndarray[np.float32_t, ndim=2] dets, np.float32_t thresh):
cdef np.ndarray[np.int64_t, ndim=1] order = scores.argsort()[::-1]

cdef int ndets = dets.shape[0]
cdef np.ndarray[np.int_t, ndim=1] suppressed = \
cdef np.ndarray[np.int32_t, ndim=1] suppressed = \
np.zeros((ndets), dtype=int)

# nominal indices
Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
def main():
reqs = [
"numba",
"imageio==2.9.0",
"imageio>=2.9.0",
"matplotlib",
"numpy",
"opencv-python",
Expand All @@ -48,13 +48,12 @@ def main():
"termcolor",
"tqdm",
"pycocotools",
"lap==0.4.0",
"motmetrics==1.2.5",
"omegaconf==2.3.0",
"pillow<=9.2.0",
"detection-tools==0.3",
"scikit-image==0.19.3",
"nuscenes-devkit==1.1.10",
"motmetrics>=1.2.5",
"omegaconf>=2.3.0",
"pillow>=9.2.0",
"detection-tools>=0.3",
"scikit-image>=0.19.3",
"nuscenes-devkit>=1.1.10",
]

model_zoo_version = "2.13.0"
Expand Down