open-mmlab/mmdetection · error · ImportError
please run pip install seaborn
Error message
please run pip install seaborn
What it means
Raised by _cv2_show_tracks/imshow_mot_errors when seaborn is not importable. The MOT error visualization code uses seaborn color palettes to colorize ID switches/FN/FP tracks, so the module refuses to run without it.
Source
Thrown at mmdet/utils/mot_error_visualize.py:70
Defaults to 2.
font_scale (float, optional): Font scale to draw id and score.
Defaults to 0.4.
text_width (int, optional): Width to draw id and score.
Defaults to 10.
text_height (int, optional): Height to draw id and score.
Defaults to 15.
show (bool, optional): Whether to show the image on the fly.
Defaults to False.
wait_time (int, optional): Value of waitKey param.
Defaults to 100.
out_file (str, optional): The filename to write the image.
Defaults to None.
Returns:
ndarray: Visualized image.
"""
if sns is None:
raise ImportError('please run pip install seaborn')
assert bboxes.ndim == 2, \
f' bboxes ndim should be 2, but its ndim is {bboxes.ndim}.'
assert ids.ndim == 1, \
f' ids ndim should be 1, but its ndim is {ids.ndim}.'
assert error_types.ndim == 1, \
f' error_types ndim should be 1, but its ndim is {error_types.ndim}.'
assert bboxes.shape[0] == ids.shape[0], \
'bboxes.shape[0] and ids.shape[0] should have the same length.'
assert bboxes.shape[1] == 5, \
f' bboxes.shape[1] should be 5, but its {bboxes.shape[1]}.'
bbox_colors = sns.color_palette()
# red, yellow, blue
bbox_colors = [bbox_colors[3], bbox_colors[1], bbox_colors[0]]
bbox_colors = [[int(255 * _c) for _c in bbox_color][::-1]
for bbox_color in bbox_colors]
if isinstance(img, str):View on GitHub (pinned to cfd5d3a985)
Solutions
- pip install seaborn
- Or skip MOT error visualization and inspect result dumps instead
Example fix
// before imshow_mot_errors(img, bboxes, ids, error_types) # ImportError // after # pip install seaborn imshow_mot_errors(img, bboxes, ids, error_types)
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec('seaborn') is None:
raise SystemExit('seaborn required for MOT error visualization: pip install seaborn') Try / catch
try:
imshow_mot_errors(...)
except ImportError as e:
if 'seaborn' in str(e):
print('skip MOT error vis:', e) Prevention
- Install mmdet extras for visualization components you use
- Gate visualization features on find_spec('seaborn') before calling
When it happens
Trigger: Calling imshow_mot_errors (or _cv2_show_wrong_tracks) in mmdet/utils/mot_error_visualize.py in an environment where `import seaborn` failed (sns is None).
Common situations: Using mmdet MOT visualization tools in a minimal install that only has mmdet core dependencies; seaborn is an extra, not a hard requirement.
Related errors
- motmetrics is not installed, please install it by: pip insta
- Invalid type for palette: {type(palette)}
- palette does not exist, random is used by default. You can a
- palette does not exist, random is used by default. You can a
- dataset_meta or class names are missed, use None by default.
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/93c69bb4fbea8883.
Report an issue: GitHub.