open-mmlab/mmdetection · error · RuntimeError
Please run "pip install openmim" and run "mim install mmpret
Error message
Please run "pip install openmim" and run "mim install mmpretrain" to install mmpretrain first.
What it means
ReIDDataPreprocessor.__init__ raises RuntimeError when the optional mmpretrain package is not importable. The ReID training pipeline (e.g. for MOT/DeepSORT) depends on mmpretrain for its loss utilities.
Source
Thrown at mmdet/models/data_preprocessors/reid_data_preprocessor.py:90
to_onehot (bool): Whether to generate one-hot format gt-labels and set
to data samples. Defaults to False.
num_classes (int, optional): The number of classes. Defaults to None.
batch_augments (dict, optional): The batch augmentations settings,
including "augments" and "probs". For more details, see
:class:`mmpretrain.models.RandomBatchAugment`.
"""
def __init__(self,
mean: Sequence[Number] = None,
std: Sequence[Number] = None,
pad_size_divisor: int = 1,
pad_value: Number = 0,
to_rgb: bool = False,
to_onehot: bool = False,
num_classes: Optional[int] = None,
batch_augments: Optional[dict] = None):
if mmpretrain is None:
raise RuntimeError('Please run "pip install openmim" and '
'run "mim install mmpretrain" to '
'install mmpretrain first.')
super().__init__()
self.pad_size_divisor = pad_size_divisor
self.pad_value = pad_value
self.to_rgb = to_rgb
self.to_onehot = to_onehot
self.num_classes = num_classes
if mean is not None:
assert std is not None, 'To enable the normalization in ' \
'preprocessing, please specify both `mean` and `std`.'
# Enable the normalization in preprocessing.
self._enable_normalize = True
self.register_buffer('mean',
torch.tensor(mean).view(-1, 1, 1), False)
self.register_buffer('std',
torch.tensor(std).view(-1, 1, 1), False)View on GitHub (pinned to cfd5d3a985)
Solutions
- pip install openmim && mim install mmpretrain
- Verify with python -c 'import mmpretrain'
- Or avoid ReID configs if mmpretrain is not needed
Example fix
// shell pip install openmim mim install mmpretrain
Defensive patterns
Strategy: validation
Validate before calling
try:\n import mmpretrain # noqa\nexcept ImportError:\n raise SystemExit('Run: mim install mmpretrain') Prevention
- Install optional dependencies before running tracking/ReID configs
- Smoke-test imports of optional packages in environment setup scripts
When it happens
Trigger: Instantiating ReIDDataPreprocessor in a tracking (ByteTrack/DeepSORT) training config without mmpretrain installed; only mmdet is installed in the environment.
Common situations: Setting up MOT ReID training environments; missing optional dependency after a fresh mmdet install.
Related errors
- Please run "pip install openmim" and run "mim install mmpret
- Please run "pip install openmim" and run "mim install mmpret
- only {num_videos} videos loaded,but {self.world_size} gpus w
- trackeval is not installed,please install it by: pip install
- metric must be a list or a str.
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/200156d340a7b914.
Report an issue: GitHub.