Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Asthestarsfalll committed Jul 13, 2023
1 parent 5112683 commit 934ec76
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions paddleseg/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ def __call__(self, data):
"""
if 'img' not in data.keys():
raise ValueError("`data` must include `img` key.")
if isinstance(data['img'], str):
if data['img'] is None:
raise TypeError(
"Expect `data[img]` to be str or np.ndarray, but got NoneType.")
elif isinstance(data['img'], str):
img = cv2.imread(data['img'], self.read_flag)
if img is None:
raise ValueError('Can\'t read The image file {}!'.format(data['img']))
data['img'] = img.astype('float32')

if not isinstance(data['img'], np.ndarray):
raise TypeError("Image type is not numpy.")
raise TypeError(
"Expect image to be np.ndarray, but got {}".format(type(data['img'])))

img_channels = 1 if data['img'].ndim == 2 else data['img'].shape[2]
if img_channels != self.img_channels:
Expand Down

0 comments on commit 934ec76

Please sign in to comment.