Skip to content

Commit

Permalink
Update image.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hgaiser authored Jul 26, 2019
1 parent 27011ec commit e27df4c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions keras_retinanet/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def read_image_bgr(path):
Args
path: Path to the image.
"""
# We deliberately don't use cv2.imread here, since it gives no feedback on errors while reading the image.
image = np.asarray(Image.open(path).convert('RGB'))
return image[:, :, ::-1].copy()

Expand Down

2 comments on commit e27df4c

@CodeJjang
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hgaiser I am interested to know, what feedback errors where you lacking from OpenCV?
Because using it should be orders of scale faster than PIL, if I know what features you were missing perhaps I could work on it.

@hgaiser
Copy link
Contributor Author

@hgaiser hgaiser commented on e27df4c Jun 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenCV doesn't provide any feedback on why image loading failed. The most straightforward case of trying to load an image file that doesn't exist just returns None, whereas PIL returns :

FileNotFoundError: [Errno 2] No such file or directory: 'foo.png'

I've briefly looked at more optimized loaders a long time ago, because I also noticed that OpenCV was faster than PIL for loading an image. Back then I decided to use PIL for it's verbosity in output, but if you have an alternative that is faster and provides similar feedback, it would be very nice. Pluspoints for not introducing a new dependency, but that's not a primary goal.

Please sign in to comment.