diff --git a/mmcv/transforms/loading.py b/mmcv/transforms/loading.py index 131558db32..6028837eca 100644 --- a/mmcv/transforms/loading.py +++ b/mmcv/transforms/loading.py @@ -105,6 +105,8 @@ def transform(self, results: dict) -> Optional[dict]: return None else: raise e + # in some cases, images are not read successfully, the img would be + # `None`, refer to https://github.com/open-mmlab/mmpretrain/issues/1427 assert img is not None, f'failed to load image: {filename}' if self.to_float32: img = img.astype(np.float32)