ValueError: X.shape[1] = 128 should be equal to 512, the number of features at training time

橙三吉。 提交于 2019-12-11 04:50:59

问题


Currently i am working on facial recognition and i am having the following issue with the given code.

for i in range(nrof_faces):
    emb_array = np.zeros((1, embedding_size))

    bb[i][0] = det[i][0]
    bb[i][1] = det[i][1]    
    bb[i][2] = det[i][2]
    bb[i][3] = det[i][3]

    # inner exception
    if bb[i][0] <= 0 or bb[i][1] <= 0 or bb[i][2] >= len(frame[0]) or bb[i] 
        [3] >= len(frame):
        print('Face is very close!')
        continue

    cropped.append(frame[bb[i][1]:bb[i][3], bb[i][0]:bb[i][2], :])
    cropped[i] = facenet.flip(cropped[i], False)
    scaled.append(misc.imresize(cropped[i], (image_size, image_size), 
             interp='bilinear'))
    scaled[i] = cv2.resize(scaled[i], (input_image_size,input_image_size),
                       interpolation=cv2.INTER_CUBIC)
    scaled[i] = facenet.prewhiten(scaled[i]) 

scaled_reshape.append(scaled[i].reshape(-1,input_image_size,input_image_size,3))

    feed_dict = {images_placeholder: scaled_reshape[i], phase_train_placeholder: False}
    emb_array[0, :] = sess.run(embeddings, feed_dict=feed_dict)
    predictions = model.predict_proba(emb_array)
    print(predictions)

And it is giving me following error:

Traceback (most recent call last):
File "F:\std\programs\python\Camera\Facenet-Real-time-face-recognition-using-deep-learning-Tensorflow\test_video.py", line 107, in <module>
  predictions = model.predict_proba(emb_array)
File "C:\Program Files\Python36\lib\site-packages\sklearn\svm\base.py", line 613, in _predict_proba
  X = self._validate_for_predict(X)
File "C:\Program Files\Python36\lib\site-packages\sklearn\svm\base.py", line 478, in _validate_for_predict
  (n_features, self.shape_fit_[1]))
ValueError: X.shape[1] = 128 should be equal to 512, the number of features at training time

来源:https://stackoverflow.com/questions/53266795/valueerror-x-shape1-128-should-be-equal-to-512-the-number-of-features-at-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!