Permalink
Browse files

Fixes #3594.

  • Loading branch information...
mth4saurabh committed Jul 31, 2015
1 parent 0015659 commit f38aea4bee7f54fc58de7eaf23c07e1d6f7943d3
Showing with 10 additions and 1 deletion.
  1. +10 −1 sklearn/datasets/lfw.py
@@ -155,7 +155,16 @@ def _load_imgs(file_paths, slice_, color, resize):
for i, file_path in enumerate(file_paths):
if i % 1000 == 0:
logger.info("Loading face #%05d / %05d", i + 1, n_faces)
face = np.asarray(imread(file_path)[slice_], dtype=np.float32)
# Checks if jpeg reading worked. Refer to issue #3594 for more
# details.
img = imread(file_path)
if img.ndim is 0:
raise RuntimeError("Failed to read the image file %s, "
"Please make sure that libjpeg is installed"
% file_path)
face = np.asarray(img[slice_], dtype=np.float32)
face /= 255.0 # scale uint8 coded colors to the [0.0, 1.0] floats
if resize is not None:
face = imresize(face, resize)

0 comments on commit f38aea4

Please sign in to comment.