Skip to content

Commit

Permalink
Remove arbitrary try except clause for load_image
Browse files Browse the repository at this point in the history
  • Loading branch information
sooahleex committed Mar 6, 2024
1 parent a4ff9cb commit a826868
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/datumaro/util/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,11 @@ def decode_image_context(image_backend: ImageBackend, image_color_channel: Image
IMAGE_BACKEND.set(curr_ctx[0])
IMAGE_COLOR_CHANNEL.set(curr_ctx[1])


def load_image(path: str, dtype: DTypeLike = np.uint8, crypter: Crypter = NULL_CRYPTER):
"""
Reads an image in the HWC Grayscale/BGR(A) [0; 255] format (default dtype is uint8).
"""
try:
IMAGE_BACKEND.set(ImageBackend.cv2)
except ModuleNotFoundError:
IMAGE_BACKEND.set(ImageBackend.PIL)

if IMAGE_BACKEND.get() == ImageBackend.cv2:
# cv2.imread does not support paths that are not representable
Expand Down

0 comments on commit a826868

Please sign in to comment.