我不明白为什么?我的python版本是3.6.2,scikit-learn版本是v0.19.0
解决方案
此错误消息是一条红色鲱鱼:
ValueError:min_faces_per_person = 70限制太多
您的堆栈跟踪显示此错误来自_fetch_lfw_people中的... sklearn \ datasets \ lfw.py,行231
查看_fetch_lfw_people中的代码,它显示何时生成此错误
n_faces = len(文件路径)如果n_faces == 0:提高ValueError("min_faces_per_person =%d限制太严格"%min_faces_per_person)
如果找不到要处理的任何(图像)文件,则会发生这种情况.
当我使用Internet代理时遇到此错误,并且此Python代码不会为我下载文件.
为解决此问题,我手动下载了这5个文件并将其放在〜/scikit_learn_data/lfw_home文件夹中.您可以通过在lfw.py中查找RemoteFileMetadata()找到这些URL.
https://ndownloader.figshare.com/files/5976018#lfw.tgzhttps://ndownloader.figshare.com/files/5976015#lfw-funneled.tgzhttps://ndownloader.figshare.com/files/5976012#pairsDevTrain.txthttps://ndownloader.figshare.com/files/5976009#pairsDevTest.txthttps://ndownloader.figshare.com/files/5976006#pairs.txt
请记住在2个tgz文件上运行tar -xvf以提取图像文件.
I'm practicing Faces recognition example using eigenfaces and SVMs which is on the official scikit-learn website.
http://scikit-learn.org/stable/auto_examples/applications/plot_face_recognition.html#sphx-glr-auto-examples-applications-plot-face-recognition-py
But when I run here:
from __future__ import print_function
from time import time
import logging
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.model_selection import GridSearchCV
from sklearn.datasets import fetch_lfw_people
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.decomposition import PCA
from sklearn.svm import SVC
print(__doc__)
# Display progress logs on stdout
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
# #############################################################################
# Download the data, if not already on disk and load it as numpy arrays
lfw_people = fetch_lfw_people(min_faces_per_person=70, resize=0.4)
But I am getting an error that tells me:
Traceback (most recent call last):
File "D:\神经网络与深度学习\麦子学院-深度学习\(Part One)深度学习基础\代码与素材
\代码与素材(1)\03SVM\plot_face_recognition.py", line 54, in <module>
lfw_people = fetch_lfw_people(min_faces_per_person=70, resize=0.4)
File "D:\Program Files\Python36\lib\site-packages\sklearn\datasets\lfw.py", line 335, in fetch_lfw_people
min_faces_per_person=min_faces_per_person, color=color, slice_=slice_)
File "D:\Program Files\Python36\lib\site-packages\sklearn\externals\joblib\memory.py", line 562, in __call__
return self._cached_call(args, kwargs)[0]
File "D:\Program Files\Python36\lib\site-packages\sklearn\externals\joblib\memory.py", line 510, in _cached_call
out, metadata = self.call(*args, **kwargs)
File "D:\Program Files\Python36\lib\site-packages\sklearn\externals\joblib\memory.py", line 744, in call
output = self.func(*args, **kwargs)
File "D:\Program Files\Python36\lib\site-packages\sklearn\datasets\lfw.py", line 231, in _fetch_lfw_people
min_faces_per_person)
ValueError: min_faces_per_person=70 is too restrictive
I don't understand why?My python version is 3.6.2, scikit-learn version is v0.19.0
解决方案
This error message is a red herring:
ValueError: min_faces_per_person=70 is too restrictive
Your stack trace shows this error comes from ...sklearn\datasets\lfw.py", line 231, in _fetch_lfw_people
Looking at the code in _fetch_lfw_people, it shows when this error is generated
n_faces = len(file_paths)
if n_faces == 0:
raise ValueError("min_faces_per_person=%d is too restrictive" %
min_faces_per_person)
This happens if it does not find any (image) files to process.
I got this error when I was behind an internet proxy, and this Python code wouldn't download the file for me.
To solve this, I downloaded these 5 files manually and placed it in the ~/scikit_learn_data/lfw_home folder. You can find these URLs by looking for RemoteFileMetadata( in lfw.py.
https://ndownloader.figshare.com/files/5976018 #lfw.tgz
https://ndownloader.figshare.com/files/5976015 #lfw-funneled.tgz
https://ndownloader.figshare.com/files/5976012 #pairsDevTrain.txt
https://ndownloader.figshare.com/files/5976009 #pairsDevTest.txt
https://ndownloader.figshare.com/files/5976006 #pairs.txt
Do remember to run tar -xvf on the 2 tgz files to extract the image files.
这篇关于ValueError:min_faces_per_person = 70限制太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!