python - SVM with SKLearn & OpenCV -


i trying predict emotion shown on image using svm. when run code warning below , prediction not shown:

deprecationwarning: passing 1d arrays data deprecated in 0.17 , willraise valueerror in 0.19. reshape data either using x.reshape(-1, 1) if data has single feature or x.reshape(1, -1) if contains single sample. deprecationwarning)

here code training , testing:

    emotions = ["anger", "neutral"]     def make_sets(emotions):     training_data = []     training_labels = []      emotion in emotions:         training = glob.glob("try here\\%s\\*" %emotion)         item in training:             image = cv2.imread(item)              gray = cv2.cvtcolor(image, cv2.color_bgr2gray)             training_data.append(gray.ravel())             training_labels.append(emotions.index(emotion))     return training_data, training_labels      x,y = make_sets(emotions)     new_x = np.asarray(x) new_x.flatten() new_y = np.asarray(y) clf = svm.svc(kernel='linear', c=1.0) clf.fit(new_x,new_y) new_image = cv2.imread('test.jpg') gray_img = cv2.cvtcolor(new_image, cv2.color_bgr2gray) clf.predict(gray_img.ravel()) 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -