ValueError:X.shape [1] = 128应该等于512,即训练时的特征数量

时间:2018-11-12 16:57:59

标签: python tensorflow scikit-learn svm

当前,我正在进行面部识别,并且给定的代码存在以下问题。

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)

这给了我以下错误:

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

0 个答案:

没有答案