Skip to content

Commit

Permalink
[Fix] give more clues when loading img failed (#2714)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tau-J committed Sep 22, 2023
1 parent dc940ab commit 52c245c
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions mmpose/datasets/transforms/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,24 @@ def transform(self, results: dict) -> Optional[dict]:
Returns:
dict: The result dict.
"""
try:
if 'img' not in results:
# Load image from file by :meth:`LoadImageFromFile.transform`
results = super().transform(results)
else:
img = results['img']
assert isinstance(img, np.ndarray)
if self.to_float32:
img = img.astype(np.float32)

if 'img' not in results:
# Load image from file by :meth:`LoadImageFromFile.transform`
results = super().transform(results)
else:
img = results['img']
assert isinstance(img, np.ndarray)
if self.to_float32:
img = img.astype(np.float32)

if 'img_path' not in results:
results['img_path'] = None
results['img_shape'] = img.shape[:2]
results['ori_shape'] = img.shape[:2]
if 'img_path' not in results:
results['img_path'] = None
results['img_shape'] = img.shape[:2]
results['ori_shape'] = img.shape[:2]
except Exception as e:
e = type(e)(
f'`{str(e)}` occurs when loading `{results["img_path"]}`.'
'Please check whether the file exists.')
raise e

return results

0 comments on commit 52c245c

Please sign in to comment.