You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MAI/tests/test_local_bytetrack_module.py

46 lines
1.3 KiB
Python

from pathlib import Path
import importlib
import sys
import numpy as np
PROJECT_ROOT = Path(__file__).resolve().parents[1]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
def test_local_bytetrack_module_is_importable_from_project_root():
module = importlib.import_module("bytetrack_min_aggressive")
assert hasattr(module, "BYTETracker")
def test_local_bytetrack_module_file_exists_in_project_root():
assert (PROJECT_ROOT / "bytetrack_min_aggressive.py").exists()
def test_hungarian_matches_single_pair():
module = importlib.import_module("bytetrack_min_aggressive")
assert module.hungarian(np.array([[0.0]], dtype=np.float32)) == [(0, 0)]
def test_bytetrack_keeps_id_for_same_box():
module = importlib.import_module("bytetrack_min_aggressive")
tracker = module.BYTETracker(
track_high_thresh=0.02,
track_low_thresh=0.01,
new_track_thresh=0.02,
match_thresh=0.10,
min_hits=1,
)
det = np.array([[10.0, 10.0, 40.0, 40.0, 0.05]], dtype=np.float32)
first = tracker.update(det, dt=0.04)
second = tracker.update(det, dt=0.04)
assert len(first) == 1
assert len(second) == 1
assert second[0].track_id == first[0].track_id
assert second[0].hits == 2