open-mmlab/mmdetection · error · RuntimeError
motmetrics is not installed, please install
Error message
motmetrics is not installed, please install it by: pip install motmetrics
What it means
StrongSORT tracker construction checks that motmetrics imported successfully; if not, it raises RuntimeError. StrongSORT additionally needs a ReID model and KalmanFilter, but this specific error is purely the missing motmetrics package.
Source
Thrown at mmdet/models/trackers/strongsort_tracker.py:79
Defaults to 0.7.
num_tentatives (int, optional): Number of continuous frames to confirm
a track. Defaults to 2.
"""
def __init__(self,
motion: Optional[dict] = None,
obj_score_thr: float = 0.6,
reid: dict = dict(
num_samples=None,
img_scale=(256, 128),
img_norm_cfg=None,
match_score_thr=0.3,
motion_weight=0.02),
match_iou_thr: float = 0.7,
num_tentatives: int = 2,
**kwargs):
if motmetrics is None:
raise RuntimeError('motmetrics is not installed,\
please install it by: pip install motmetrics')
super().__init__(motion, obj_score_thr, reid, match_iou_thr,
num_tentatives, **kwargs)
def update_track(self, id: int, obj: Tuple[Tensor]) -> None:
"""Update a track."""
for k, v in zip(self.memo_items, obj):
v = v[None]
if self.momentums is not None and k in self.momentums:
m = self.momentums[k]
self.tracks[id][k] = (1 - m) * self.tracks[id][k] + m * v
else:
self.tracks[id][k].append(v)
if self.tracks[id].tentative:
if len(self.tracks[id]['bboxes']) >= self.num_tentatives:
self.tracks[id].tentative = False
bbox = bbox_xyxy_to_cxcyah(self.tracks[id].bboxes[-1]) # size = (1, 4)View on GitHub (pinned to cfd5d3a985)
Solutions
- pip install motmetrics
- Ensure the same interpreter is used (pip from the right conda env)
- Install the other tracking extras (lap, scipy, scikit-learn) in one go
Example fix
# before: RuntimeError: motmetrics is not installed # after pip install motmetrics lap scipy scikit-learn
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
assert importlib.util.find_spec('motmetrics'), 'pip install motmetrics' Try / catch
try:
tracker = StrongSORTTracker(...)
except RuntimeError as e:
if 'motmetrics' in str(e):
raise SystemExit('Missing dependency: pip install motmetrics')
raise Prevention
- Use one requirements set for all trackers: motmetrics, lap, scipy, scikit-learn
- Install extras in the same conda env used for training
When it happens
Trigger: tracker=dict(type='StrongSORTTracker', reid=...) built in an environment lacking py-motmetrics.
Common situations: Running StrongSORT configs (strongsort_yolox_x_8xb4-80e_mot17) on minimal mmdet installs or misconfigured conda envs.
Related errors
- motmetrics is not installed, please install
- trackeval is not installed,please install it by: pip install
- sscikit-learn is not installed, please insta
- sscikit-learn is not installed, please insta
- lap is not installed, please install it by:
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/7bd6d8dcd01fd154.
Report an issue: GitHub.