我正在尝试按照我在网上找到的这个很棒的教程的说明通过照片识别人:Modern Face Recognition with Deep Learning
该项目使用 Python、Openface 和 dlib 来完成任务
我已经能够设置一切并正常工作,但在运行以下命令时遇到问题:
python3 ./demos/classifier.py train ./generated-embeddings/
在我的终端上执行上述命令给了我以下错误:
> /usr/local/lib/python3.5/dist-packages/sklearn/utils/fixes.py:64: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead
if ‘order’ in inspect.getargspec(np.copy)[0]:
Loading embeddings.
Traceback (most recent call last):
File “./demos/classifier.py”, line 291, in <module>
train(args)
File “./demos/classifier.py”, line 112, in train
le = LabelEncoder().fit(labels)
File “/usr/local/lib/python3.5/dist-packages/sklearn/preprocessing/label.py”, line 110, in fit
y = column_or_1d(y, warn=True)
File “/usr/local/lib/python3.5/dist-packages/sklearn/utils/validation.py”, line 485, in column_or_1d
raise ValueError(“bad input shape {0}”.format(shape))
ValueError: bad input shape ()
我的设置:
有没有人知道发生了什么以及如何解决这个问题?
我解决了该错误,并在此处发布了解决方案,希望它对遇到此问题的任何其他用户有用。
所述坏输入形状误差执行该命令来
python3 ./demos/classifier.py train ./generated-embeddings/
可以通过修改文件openface/demos/classifier.py通过添加以下代码行轻松解决
labels=list(labels)
在 fit 函数调用之前
le = LabelEncoder().fit(labels)
默认情况下 type(labels) 返回 map ,这就是导致错误的原因,因为 LabelEncoder.fit() 函数接受一个类似数组的形状 (n_samples,) 而不是 map 对象作为输入。
希望这有帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句