Skip to content

Commit

Permalink
fix: raise FileNotFound with proper Path
Browse files Browse the repository at this point in the history
  • Loading branch information
furiosamg committed Aug 10, 2023
1 parent 105e280 commit bcd8f03
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions furiosa/models/vision/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ def resize_with_aspect_ratio(
def read_image_opencv_if_needed(image: Union[str, os.PathLike, ndarray]):
if isinstance(image, ndarray):
return image
if isinstance(image, os.PathLike):
image = image.__fspath__() # imread only accepts str (opencv/opencv#15731)
image = cv2.imread(image)
elif isinstance(image, os.PathLike):
path = image.__fspath__() # imread only accepts str (opencv/opencv#15731)
else:
path = image
image = cv2.imread(path)
if image is None:
raise FileNotFoundError(image)
raise FileNotFoundError(path)
return image

0 comments on commit bcd8f03

Please sign in to comment.