lfw分类 python_无法在sklearn中使用LFW数据集

在尝试使用sklearn.datasets.fetch_lfw_people()加载LFW人脸识别数据集时,遇到了IOError,问题可能源于数据集文件无法被正确识别。代码中通过numpy和scipy库读取图片时出现了问题,需要检查数据集路径的正确性以及文件的兼容性。
摘要由CSDN通过智能技术生成

好像找人功能不起作用,但我不明白为什么。在

测试代码如下:In [1]: import numpy as np

In [2]: from sklearn import datasets

In [3]: lfw= datasets.fetch_lfw_people()

IOError Traceback (most recent call last)

in ()

----> 1 lfw= datasets.fetch_lfw_people()

C:\Python27\lib\site-packages\sklearn\datasets\lfw.pyc in fetch_lfw_people(data_

home, funneled, resize, min_faces_per_person, color, slice_, download_if_missing

)

270 faces, target, target_names = load_func(

271 data_folder_path, resize=resize,

--> 272 min_faces_per_person=min_faces_per_person, color=color, slice_=s

lice_)

273

274 # pack the results as a Bunch instance

C:\Python27\lib\site-packages\sklearn\externals\joblib\memory.pyc in __call__(se

lf, *args, **kwargs)

169 'directory %s'

170 % (name, argument_hash, output_dir))

--> 171 return self.call(*args, **kwargs)

172 else:

173 try:

C:\Python27\lib\site-packages\sklearn\externals\joblib\memory.pyc in call(self,

*args, **kwargs)

321 if self._verbose:

322 print self.format_call(*args, **kwargs)

--> 323 output = self.func(*args, **kwargs)

324 self._persist_output(output, output_dir)

325 duration = time.time() - start_time

C:\Python27\lib\site-packages\sklearn\datasets\lfw.pyc in _fetch_lfw_people(data

_folder_path, slice_, color, resize, min_faces_per_person)

195 target = np.searchsorted(target_names, person_names)

196

--> 197 faces = _load_imgs(file_paths, slice_, color, resize)

198

199 # shuffle the faces with a deterministic RNG scheme to avoid having

C:\Python27\lib\site-packages\sklearn\datasets\lfw.pyc in _load_imgs(file_paths,

slice_, color, resize)

149 if i % 1000 == 0:

150 logger.info("Loading face #%05d / %05d", i + 1, n_faces)

--> 151 face = np.asarray(imread(file_path)[slice_], dtype=np.float32)

152 face /= 255.0 # scale uint8 coded colors to the [0.0, 1.0] floa

ts

153 if resize is not None:

C:\Python27\lib\site-packages\scipy\misc\pilutil.pyc in imread(name, flatten)

100 """

101

--> 102 im = Image.open(name)

103 return fromimage(im,flatten=flatten)

104

C:\Python27\lib\site-packages\PIL\Image.pyc in open(fp, mode)

1978 pass

1979

-> 1980 raise IOError("cannot identify image file")

1981

1982 #

IOError: cannot identify image file

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值