Skip to content

Commit ac54a8f

Browse files
committed
Load images as RGB using OpenCV too. Fixes #78
Interestingly, the results on VGG from ImageNet don't differ much! This observation is a qualitative one, not quantitative.
1 parent 253f930 commit ac54a8f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

DeepFried2/datasets/images.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ def imread(fname, dtype=_np.float32):
88
im = _cv2.imread(fname, flags=_cv2.IMREAD_UNCHANGED)
99
if im is None:
1010
raise IOError("Couldn't open image file {}".format(fname))
11+
# Convert BGR to RGB. OpenCV is weird like that.
12+
if im.ndim == 3 and im.shape[-1] == 3:
13+
im = im[:,:,::-1]
1114
return im.astype(dtype)
1215

1316
def imresize(im, h, w):

0 commit comments

Comments
 (0)