{"record":{"id":"543ecf990d80d0cc","repo":"open-mmlab/mmdetection","slug":"please-run-pip-install-openmim-and-run-mim-inst-543ecf","errorCode":null,"errorMessage":"Please run \"pip install openmim\" and run \"mim install mmpretrain\" to install mmpretrain first.","messagePattern":"Please run \"pip install openmim\" and run \"mim install mmpretrain\" to install mmpretrain first\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"mmdet/models/reid/base_reid.py","lineNumber":23,"sourceCode":"\ntry:\n    import mmpretrain\n    from mmpretrain.models.classifiers import ImageClassifier\nexcept ImportError:\n    mmpretrain = None\n    ImageClassifier = object\n\nfrom mmdet.registry import MODELS\nfrom mmdet.structures import ReIDDataSample\n\n\n@MODELS.register_module()\nclass BaseReID(ImageClassifier):\n    \"\"\"Base model for re-identification.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        if mmpretrain is None:\n            raise RuntimeError('Please run \"pip install openmim\" and '\n                               'run \"mim install mmpretrain\" to '\n                               'install mmpretrain first.')\n        super().__init__(*args, **kwargs)\n\n    def forward(self,\n                inputs: torch.Tensor,\n                data_samples: Optional[List[ReIDDataSample]] = None,\n                mode: str = 'tensor'):\n        \"\"\"The unified entry for a forward process in both training and test.\n\n        The method should accept three modes: \"tensor\", \"predict\" and \"loss\":\n\n        - \"tensor\": Forward the whole network and return tensor or tuple of\n          tensor without any post-processing, same as a common nn.Module.\n        - \"predict\": Forward and return the predictions, which are fully\n          processed to a list of :obj:`ReIDDataSample`.\n        - \"loss\": Forward and return a dict of losses according to the given\n          inputs and data samples.","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/reid/base_reid.py#L5-L41","documentation":"BaseReID subclasses mmpretrain's ImageClassifier, which is only available if mmpretrain is installed. __init__ raises RuntimeError at construction time when the mmpretrain import failed (mmpretrain is None), telling you to install it via mim.","triggerScenarios":"Building any ReID model (BaseReID and subclasses like GFocalReID, LinearReIDHead-based classifiers) without mmpretrain installed; e.g. training QDTrack/DeepSORT reid configs in a bare mmdet environment.","commonSituations":"Fresh mmdetection install without the optional mmpretrain dependency; version mismatch where mmpretrain import raises inside mmdet's try/except, silently becoming None.","solutions":["pip install openmim && mim install mmpretrain","If mim install fails, install a compatible pinned version: pip install mmpretrain>=1.0.0 matching your mmdet version","Verify with python -c \"import mmpretrain\" that the import succeeds (a failing import also triggers this error)"],"exampleFix":"# before\nmmdet installed only -> building reid model raises\n# after\npip install -U openmim\nmim install mmpretrain","handlingStrategy":"validation","validationCode":"try:\n    import mmpretrain  # noqa\n    ok = True\nexcept Exception:\n    ok = False\nassert ok, 'install mmpretrain before building ReID models'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install mmpretrain via mim to get matching versions","Smoke-test `import mmpretrain` in CI before training reid configs"],"tags":["mmdetection","mmpretrain","reid","missing-dependency"],"backgroundTag":"missing-optional-dependency","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}