Unverified Commit 387b63b3 authored by Ezra-Yu's avatar Ezra-Yu Committed by GitHub
Browse files

[Enhance] Raise a error if fails to read image (#2791)



* add assert

* Update mmcv/transforms/loading.py
Co-authored-by: default avatarZaida Zhou <58739961+zhouzaida@users.noreply.github.com>

* update comments

---------
Co-authored-by: default avatarZaida Zhou <58739961+zhouzaida@users.noreply.github.com>
parent 9a5685a9
...@@ -105,6 +105,9 @@ class LoadImageFromFile(BaseTransform): ...@@ -105,6 +105,9 @@ class LoadImageFromFile(BaseTransform):
return None return None
else: else:
raise e 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: if self.to_float32:
img = img.astype(np.float32) img = img.astype(np.float32)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment