open-mmlab/mmdetection · error · RuntimeError
imagecorruptions is not installed
Error message
imagecorruptions is not installed
What it means
PhotoMetricDistortion-like Corrupt transform (mmdet) requires the optional `imagecorruptions` package to apply synthetic corruptions (gaussian noise, fog, etc.). At runtime, if the lazy import failed, the transform raises RuntimeError immediately.
Source
Thrown at mmdet/datasets/transforms/transforms.py:1530
severity (int): The severity of corruption. Defaults to 1.
"""
def __init__(self, corruption: str, severity: int = 1) -> None:
self.corruption = corruption
self.severity = severity
def transform(self, results: dict) -> dict:
"""Call function to corrupt image.
Args:
results (dict): Result dict from loading pipeline.
Returns:
dict: Result dict with images corrupted.
"""
if corrupt is None:
raise RuntimeError('imagecorruptions is not installed')
results['img'] = corrupt(
results['img'].astype(np.uint8),
corruption_name=self.corruption,
severity=self.severity)
return results
def __repr__(self) -> str:
repr_str = self.__class__.__name__
repr_str += f'(corruption={self.corruption}, '
repr_str += f'severity={self.severity})'
return repr_str
@TRANSFORMS.register_module()
@avoid_cache_randomness
class Albu(BaseTransform):
"""Albumentation augmentation.
View on GitHub (pinned to cfd5d3a985)
Solutions
- pip install imagecorruptions
- Verify import: python -c "from imagecorruptions import corrupt"
- Remove the Corrupt transform if robustness testing is not intended
Example fix
# before pipeline=[dict(type='Corrupt', corruption='fog', severity=3)] # after pip install imagecorruptions # keep the pipeline unchanged
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
assert importlib.util.find_spec('imagecorruptions') is not None, 'install imagecorruptions' Try / catch
try:
from mmdet.datasets.transforms import Corrupt
out = Corrupt(corruption='fog', severity=3).transform(results)
except RuntimeError as e:
if 'imagecorruptions' in str(e):
raise SystemExit('pip install imagecorruptions') from e Prevention
- Install extras before running robustness configs
- Gate corruption benchmarks behind a dependency check in scripts
When it happens
Trigger: Using a pipeline config containing dict(type='Corrupt', corruption='gaussian_noise', severity=...) in testing pipelines (e.g. robustness benchmarks on COCO-C) without imagecorruptions installed.
Common situations: Running corruption/robustness test configs (COCO-C, VOC-C) in a fresh environment; extra deps are not installed by default `pip install mmdet`.
Related errors
- albumentations is not installed
- If you want to reduce GPU memory usage,
- If you want to reduce GPU memory usage,
- If you want to reduce GPU memory usage,
- mmlvis is deprecated, please install official lvis-api by "p
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/1ce279181303578c.
Report an issue: GitHub.