-1

I am trying to recognize people by photo following the instructions of this great tutorial I found online: Modern Face Recognition with Deep Learning

This project uses Python, Openface and dlib in order to accomplish the task

I have been able to set everything up and working correctly but am experiencing issues in running the following command:

python3 ./demos/classifier.py train ./generated-embeddings/

Executing the above mentioned command on my terminal gives me the following error:

> /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 ()

My setup:

  • UBUNTU 16.04 LTS 64 BIT
  • Python 3.5.2
  • dlib 19.7.0
  • openface

Does anybody have an idea of what's going on and how to fix this?

SiHa
  • 7,830
  • 13
  • 34
  • 43
Employee
  • 3,109
  • 5
  • 31
  • 50

1 Answers1

1

I solved the error and I post here the solution hoping it will be useful for any other user experiencing this issue.

The bad input shape error coming from executing the command

python3 ./demos/classifier.py train ./generated-embeddings/

can be easily solved by modifying the file openface/demos/classifier.py by adding the following line of code

labels=list(labels)

before the fit function call

le = LabelEncoder().fit(labels)

By default type(labels) returns map and that's what is causing the error because the LabelEncoder.fit() function accepts as input an array-like of shape (n_samples,) and not a map object.

Hope this help

Employee
  • 3,109
  • 5
  • 31
  • 50