Skip to content

Commit 11d33bc

Browse files
committed
Merge pull request scikit-learn#5071 from mth4saurabh/fix-issue-3594
[MRG] Fixes scikit-learn#3594.
2 parents 0015659 + f38aea4 commit 11d33bc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

sklearn/datasets/lfw.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,16 @@ def _load_imgs(file_paths, slice_, color, resize):
155155
for i, file_path in enumerate(file_paths):
156156
if i % 1000 == 0:
157157
logger.info("Loading face #%05d / %05d", i + 1, n_faces)
158-
face = np.asarray(imread(file_path)[slice_], dtype=np.float32)
158+
159+
# Checks if jpeg reading worked. Refer to issue #3594 for more
160+
# details.
161+
img = imread(file_path)
162+
if img.ndim is 0:
163+
raise RuntimeError("Failed to read the image file %s, "
164+
"Please make sure that libjpeg is installed"
165+
% file_path)
166+
167+
face = np.asarray(img[slice_], dtype=np.float32)
159168
face /= 255.0 # scale uint8 coded colors to the [0.0, 1.0] floats
160169
if resize is not None:
161170
face = imresize(face, resize)

0 commit comments

Comments
 (0)