{"record":{"id":"e479be644232fb0f","repo":"open-mmlab/mmdetection","slug":"motmetrics-is-not-installed-please-install-it-by","errorCode":null,"errorMessage":"motmetrics is not installed, please install it by: pip install seaborn","messagePattern":"motmetrics is not installed, please install it by: pip install seaborn","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mmdet/visualization/local_visualizer.py","lineNumber":512,"sourceCode":"\n        # It is convenient for users to obtain the drawn image.\n        # For example, the user wants to obtain the drawn image and\n        # save it as a video during video inference.\n        self.set_image(drawn_img)\n\n        if show:\n            self.show(drawn_img, win_name=name, wait_time=wait_time)\n\n        if out_file is not None:\n            mmcv.imwrite(drawn_img[..., ::-1], out_file)\n        else:\n            self.add_image(name, drawn_img, step)\n\n\ndef random_color(seed):\n    \"\"\"Random a color according to the input seed.\"\"\"\n    if sns is None:\n        raise RuntimeError('motmetrics is not installed,\\\n                 please install it by: pip install seaborn')\n    np.random.seed(seed)\n    colors = sns.color_palette()\n    color = colors[np.random.choice(range(len(colors)))]\n    color = tuple([int(255 * c) for c in color])\n    return color\n\n\n@VISUALIZERS.register_module()\nclass TrackLocalVisualizer(Visualizer):\n    \"\"\"Tracking Local Visualizer for the MOT, VIS tasks.\n\n    Args:\n        name (str): Name of the instance. Defaults to 'visualizer'.\n        image (np.ndarray, optional): the origin image to draw. The format\n            should be RGB. Defaults to None.\n        vis_backends (list, optional): Visual backend config list.\n            Defaults to None.","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/visualization/local_visualizer.py#L494-L530","documentation":"random_color raises RuntimeError when seaborn is missing because it picks colors from sns.color_palette(). Note the message text is misleading — it says to install 'motmetrics' but the actual missing package is seaborn.","triggerScenarios":"Calling DetLocalVisualizer drawing paths (e.g. _draw_instances with ids, MOT/VID tracking visualization) that call random_color when sns is None.","commonSituations":"Visualizing tracking results with the local visualizer without installing seaborn; developers get confused because the message names the wrong package (a known copy-paste bug, motmetrics is unrelated).","solutions":["pip install seaborn (the message's 'pip install seaborn' is correct only at the end; motmetrics is not what's missing)","If you can't install, avoid per-id colored drawing (drop the ids argument or set show=False)"],"exampleFix":"// before\nvisualizer.draw_datasample(img, datasample)  # RuntimeError: motmetrics is not installed\n// after\n# pip install seaborn\nvisualizer.draw_datasample(img, datasample)","handlingStrategy":"validation","validationCode":"from mmdet.utils import matplotlib_utils  # noqa\nimport importlib.util\nHAS_SNS = importlib.util.find_spec('seaborn') is not None\nif not HAS_SNS:\n    print('colored per-id drawing unavailable; install seaborn')","typeGuard":null,"tryCatchPattern":"try:\n    visualizer.draw_datasample(img, data_sample)\nexcept RuntimeError as e:\n    if 'seaborn' in str(e):\n        pass  # degrade to no visualization","preventionTips":["Don't trust the message text — check for the real missing import","Keep seaborn in dev environments where visualization is used"],"tags":["python","dependency","visualization","misleading-message","seaborn"],"backgroundTag":"missing-optional-dependency","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}