PCA主成分分析+SVM实现人脸识别
原文地址:
http://ihoge.cn/2018/PCA+SVM人臉識別.html
加載數據
這里使用的測試數據共包含40位人員照片,每個人10張照片。也可登陸http://www.cl.cam.ac.uk/research/dtg/attarchive/facesataglance.html 查看400張照片的縮略圖。
import time import logging from sklearn.datasets import fetch_olivetti_faceslogging.basicConfig(level = logging.INFO, format="%(asctime)s %(message)s") # 這里INFO必須大寫data_home = 'code/datasets/' logging.info("開始加載數據") faces = fetch_olivetti_faces(data_home=data_home) logging.info("加載完成")這里做下簡單的解釋:
加載的圖片保存在faces變量里,sklaern已經把每張照片處理成剪切掉頭發部分并且64x64大小且人臉居中顯示。在真實生產環境中這一步很重要,否則模型將被大量的噪聲干擾(即照片背景,變化的發型等,這些特征都應該排除在輸入特征之外)。最后要成功下載數據集還需要安裝Python圖片圖里工具Pillow否則無法對圖片解碼。下面輸出下數據的概要信息:
import numpy as npX = faces.data y = faces.targettargets = np.unique(faces.target) target_names = np.array(["p%d" % t for t in targets]) #給每個人做標簽 n_targets = target_name.shape[0] n_samples, h, w = faces.images.shapeprint('Samples count:{}\nTarget count:{}'.format(n_samples, n_targets)) print('Image size:{}x{}\nData shape:{}'.format(w, h, X.shape)) Samples count:400 Target count:40 Image size:64x64 Data shape:(400, 4096)由輸出可知,共有40人,照片總量400,輸入特征(64x64=4096)個。
為了直觀觀察數據,從每個人物的照片里隨機選擇一張顯示,定義下畫圖工具:
其中輸入參數images是一個二維數據,每一行都是一個圖片數據。在加載數據時,fech_ollivetti_faces()函數已經自動做了預處理,圖片的每個像素的RBG值都轉換成了[0,1]浮點數。因此,畫出來的照片也是黑白的。子圖片識別領域一般用黑白照片就可以了,減少計算量的同時也更加準確。
%matplotlib inline from matplotlib import pyplot as plt def plot_gallery(images, titles, h, w, n_row=2, n_col=5): # 顯示圖片陣列:plt.figure(figsize=(2*n_col, 2.2*n_row),dpi=140)plt.subplots_adjust(bottom=0, left=.01, right=.99, top=.90, hspace=.01)for i in range(n_row * n_col):plt.subplot(n_row, n_col, i+1)plt.imshow(images[i].reshape((h,w)), cmap=plt.cm.gray)plt.title(titles[i])plt.axis('off') n_row = 2 n_col = 6sample_images = None sample_titles = [] for i in range(n_targets):people_images = X[y==i] # 注意這里傳入ipeople_sample_index = np.random.randint(0, people_images.shape[0], 1)people_sample_image = people_images[people_sample_index, :]if sample_images is not None:sample_images = np.concatenate((sample_images, people_sample_image), axis=0)else:sample_images =people_sample_imagesample_titles.append(target_names[i]) # 這里target_names是在前面生成的標簽plot_gallery(sample_images, sample_titles, h, w, n_row, n_col)#代碼中X[y=i]可以選擇除特定的所有照片,隨機選出來的照片放在sample.images數組對象里,最后調用之前定義的函數把照片畫出來。 from sklearn.model_selection import train_test_splitX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=4)支持向量機第一次嘗試
直接食用支持向量機來實現人臉識別:
from time import time from sklearn.svm import SVCt = time() clf = SVC(class_weight='balanced') clf.fit(X_train, y_train) print("耗時:{}秒".format(time() - t)) 耗時:1.0220119953155518秒1、接著對人臉數據進行預測:使用confusion_matrix查看準確性:
from sklearn.metrics import confusion_matrixy_pred = clf.predict(X_test) cm = confusion_matrix(y_test, y_pred, labels=range(n_targets)) print("confusion_matrix:\n") # np.set_printoptions(threshold=np.nan) print(cm[:10]) confusion_matrix:[[0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]上面np.set_printoptions()是為了確保cm完整輸出,這是因為這個數組是40x40的,默認情況下不會全部輸出。??
2、使用classification_report查看準確性
但是很明顯輸出結果效果很差。 因為confusion_matrix理想的輸出是矩陣的對角線上有數組,其他地方都為0,而且這里很多圖片都被預測成索引為12的類別了。我買再來看下classification_report的結果:
from sklearn.metrics import classification_reportprint(classification_report(y_test, y_pred, target_names = target_names)) #這里y_test和y_pred不要顛倒。 precision recall f1-score supportp0 0.00 0.00 0.00 1p1 0.00 0.00 0.00 3p2 0.00 0.00 0.00 2p3 0.00 0.00 0.00 1p4 0.00 0.00 0.00 1p5 0.00 0.00 0.00 1p6 0.00 0.00 0.00 4p7 0.00 0.00 0.00 2p8 0.00 0.00 0.00 4p9 0.00 0.00 0.00 2p10 0.00 0.00 0.00 1p11 0.00 0.00 0.00 0p12 0.00 0.00 0.00 4p13 0.00 0.00 0.00 4p14 0.00 0.00 0.00 1p15 0.00 0.00 0.00 1p16 0.00 0.00 0.00 3p17 0.00 0.00 0.00 2p18 0.00 0.00 0.00 2p19 0.00 0.00 0.00 2p20 0.00 0.00 0.00 1p21 0.00 0.00 0.00 2p22 0.00 0.00 0.00 3p23 0.00 0.00 0.00 2p24 0.00 0.00 0.00 3p25 0.00 0.00 0.00 3p26 0.00 0.00 0.00 2p27 0.00 0.00 0.00 2p28 0.00 0.00 0.00 0p29 0.00 0.00 0.00 2p30 0.00 0.00 0.00 2p31 0.00 0.00 0.00 3p32 0.00 0.00 0.00 2p33 0.00 0.00 0.00 2p34 0.00 0.00 0.00 0p35 0.00 0.00 0.00 2p36 0.00 0.00 0.00 3p37 0.00 0.00 0.00 1p38 0.00 0.00 0.00 2p39 0.00 0.00 0.00 2avg / total 0.00 0.00 0.00 80/Users/hadoop/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: Precision and F-score are ill-defined and being set to 0.0 in labels with no predicted samples.'precision', 'predicted', average, warn_for) /Users/hadoop/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py:1137: UndefinedMetricWarning: Recall and F-score are ill-defined and being set to 0.0 in labels with no true samples.'recall', 'true', average, warn_for)結果不出預料,果然很差。
這是因為:這里把每個像素都作為一個輸入特征來處理,這樣那個數據噪聲太嚴重了,模型根本沒有辦法對訓練數據集進行擬合。這里有4096個特征向量,可是數據集大小才400個,比特征個數少了太多,而且分出20%作為測試集。這種情況下根本無法進行準確的訓練和預測。
使用PCA來處理數據集
選擇kk值
解決上述問題的辦法有兩種,一個是加大數據樣本量(在這里這個不太現實),或者使用PCA給數據降維,值選擇前k個最重要的特征。
這里我們根據PCA算法來計算失真程度來確定k值。
在sklearn里,可以從PCA模型的explained_variance_ratio_變量里獲取經PCA處理后的數據還原率。這是一個數組,所有元素求和即可知道選擇的kk值的數據還原率。隨著kk的增大,數值會無限接近于1。
利用這一特征,可以讓kk取值10~300之間,每個30取一次樣。針對這里的情況選擇失真度小于5%即可。
from sklearn.decomposition import PCAprint("Exploring explained variance ratio for dataset ...") candidate_components = range(10, 300, 30) explained_ratios = [] t = time() for c in candidate_components:pca = PCA(n_components=c)X_pca = pca.fit_transform(X)explained_ratios.append(np.sum(pca.explained_variance_ratio_)) print('Done in {0:.2f}s'.format(time()-t)) Exploring explained variance ratio for dataset ... Done in 2.17s plt.figure(figsize=(8, 5), dpi=100) plt.grid() plt.plot(candidate_components, explained_ratios) plt.xlabel('Number of PCA Components') plt.ylabel('Explained Variance Ratio') plt.title('Explained variance ratio for PCA') plt.yticks(np.arange(0.5, 1.05, .05)) plt.xticks(np.arange(0, 300, 20));由上圖可知,若要保留95%的數據還原率,kk值選擇120即可。為了更直觀的看不同kk值的區別,這里畫出來體驗下:
def title_prefix(prefix, title):return "{}: {}".format(prefix, title)n_row = 1 n_col = 5sample_images = sample_images[0:5] sample_titles = sample_titles[0:5]plotting_images = sample_images plotting_titles = [title_prefix('orig', t) for t in sample_titles] candidate_components = [120, 75, 37, 19, 8] for c in candidate_components:print("Fitting and projecting on PCA(n_components={}) ...".format(c))t = time()pca = PCA(n_components=c)pca.fit(X)X_sample_pca = pca.transform(sample_images)X_sample_inv = pca.inverse_transform(X_sample_pca)plotting_images = np.concatenate((plotting_images, X_sample_inv), axis=0)sample_title_pca = [title_prefix('{}'.format(c), t) for t in sample_titles]plotting_titles = np.concatenate((plotting_titles, sample_title_pca), axis=0)print("Done in {0:.2f}s".format(time() - t))print("Plotting sample image with different number of PCA conpoments ...") plot_gallery(plotting_images, plotting_titles, h, w,n_row * (len(candidate_components) + 1), n_col) Fitting and projecting on PCA(n_components=120) ... Done in 0.18s Fitting and projecting on PCA(n_components=75) ... Done in 0.14s Fitting and projecting on PCA(n_components=37) ... Done in 0.11s Fitting and projecting on PCA(n_components=19) ... Done in 0.07s Fitting and projecting on PCA(n_components=8) ... Done in 0.06s Plotting sample image with different number of PCA conpoments ...利用GridSearchCV選出最優參數
接下來選擇k=120k=120作為PCA的參數對數據集和測試集進行特征提取,然后調用GridSearchCV選出最優參數
n_components = 120print("Fitting PCA by using training data ...") t = time() pca = PCA(n_components=n_components, svd_solver='randomized', whiten=True).fit(X_train) print("Done in {0:.2f}s".format(time() - t))print("Projecting input data for PCA ...") t = time() X_train_pca = pca.transform(X_train) X_test_pca = pca.transform(X_test) print("Done in {0:.2f}s".format(time() - t)) Fitting PCA by using training data ... Done in 0.16s Projecting input data for PCA ... Done in 0.01s from sklearn.model_selection import GridSearchCVprint("Searching the best parameters for SVC ...") param_grid = {'C': [1, 5, 10, 50],'gamma': [0.0001, 0.0005, 0.001, 0.005, 0.01]} clf = GridSearchCV(SVC(kernel='rbf', class_weight='balanced'), param_grid, verbose=2, n_jobs=4)# 參數n_jobs=4表示啟動4個進程 clf = clf.fit(X_train_pca, y_train) print("Best parameters found by grid search:") print(clf.best_params_) Searching the best parameters for SVC ... Fitting 3 folds for each of 20 candidates, totalling 60 fits [CV] C=1, gamma=0.0001 ............................................... [CV] C=1, gamma=0.0001 ............................................... [CV] C=1, gamma=0.0001 ............................................... [CV] C=1, gamma=0.0005 ............................................... [CV] ................................ C=1, gamma=0.0001, total= 0.1s [CV] C=1, gamma=0.0005 ............................................... [CV] ................................ C=1, gamma=0.0001, total= 0.1s [CV] C=1, gamma=0.0005 ............................................... [CV] ................................ C=1, gamma=0.0001, total= 0.1s [CV] C=1, gamma=0.001 ................................................ [CV] ................................ C=1, gamma=0.0005, total= 0.1s [CV] C=1, gamma=0.001 ................................................ [CV] ................................ C=1, gamma=0.0005, total= 0.1s [CV] C=1, gamma=0.001 ................................................ [CV] ................................ C=1, gamma=0.0005, total= 0.1s [CV] C=1, gamma=0.01 ................................................. [CV] ................................. C=1, gamma=0.001, total= 0.1s [CV] C=5, gamma=0.0001 ............................................... [CV] ................................. C=1, gamma=0.001, total= 0.1s [CV] C=5, gamma=0.0005 ............................................... [CV] ................................. C=1, gamma=0.001, total= 0.1s [CV] C=1, gamma=0.005 ................................................ [CV] .................................. C=1, gamma=0.01, total= 0.1s [CV] C=1, gamma=0.01 ................................................. [CV] ................................ C=5, gamma=0.0001, total= 0.1s [CV] C=5, gamma=0.0001 ............................................... [CV] ................................ C=5, gamma=0.0005, total= 0.1s [CV] C=5, gamma=0.001 ................................................ [CV] ................................. C=1, gamma=0.005, total= 0.1s [CV] C=1, gamma=0.005 ................................................ [CV] .................................. C=1, gamma=0.01, total= 0.1s [CV] C=1, gamma=0.01 ................................................. [CV] ................................ C=5, gamma=0.0001, total= 0.1s [CV] C=5, gamma=0.0005 ............................................... [CV] ................................. C=5, gamma=0.001, total= 0.1s [CV] C=5, gamma=0.001 ................................................ [CV] ................................. C=1, gamma=0.005, total= 0.1s [CV] C=1, gamma=0.005 ................................................ [CV] ................................ C=5, gamma=0.0005, total= 0.1s [CV] C=5, gamma=0.0005 ............................................... [CV] .................................. C=1, gamma=0.01, total= 0.1s [CV] C=5, gamma=0.0001 ............................................... [CV] ................................. C=5, gamma=0.001, total= 0.1s [CV] C=5, gamma=0.001 ................................................ [CV] ................................. C=1, gamma=0.005, total= 0.1s [CV] ................................ C=5, gamma=0.0005, total= 0.1s [CV] C=5, gamma=0.005 ................................................ [CV] C=5, gamma=0.01 ................................................. [CV] ................................ C=5, gamma=0.0001, total= 0.1s [CV] C=10, gamma=0.0001 .............................................. [CV] ................................. C=5, gamma=0.001, total= 0.1s [CV] C=10, gamma=0.001 ............................................... [CV] ................................. C=5, gamma=0.005, total= 0.1s [CV] C=5, gamma=0.005 ................................................ [CV] .................................. C=5, gamma=0.01, total= 0.1s [CV] C=5, gamma=0.01 ................................................. [CV] ............................... C=10, gamma=0.0001, total= 0.1s [CV] C=10, gamma=0.0005 .............................................. [CV] ................................ C=10, gamma=0.001, total= 0.1s [CV] C=10, gamma=0.001 ............................................... [CV] ................................. C=5, gamma=0.005, total= 0.1s [CV] C=5, gamma=0.005 ................................................ [CV] ............................... C=10, gamma=0.0005, total= 0.1s [CV] C=10, gamma=0.0005 .............................................. [CV] .................................. C=5, gamma=0.01, total= 0.1s [CV] C=10, gamma=0.0001 .............................................. [CV] ................................ C=10, gamma=0.001, total= 0.1s [CV] C=10, gamma=0.001 ............................................... [CV] ................................. C=5, gamma=0.005, total= 0.1s [CV] C=5, gamma=0.01 ................................................. [CV] ............................... C=10, gamma=0.0001, total= 0.1s [CV] C=10, gamma=0.0001 .............................................. [CV] ............................... C=10, gamma=0.0005, total= 0.1s [CV] C=10, gamma=0.0005 .............................................. [CV] ................................ C=10, gamma=0.001, total= 0.1s [CV] C=10, gamma=0.005 ............................................... [CV] .................................. C=5, gamma=0.01, total= 0.1s [CV] C=10, gamma=0.005 ............................................... [CV] ............................... C=10, gamma=0.0001, total= 0.1s [CV] C=10, gamma=0.01 ................................................ [CV] ............................... C=10, gamma=0.0005, total= 0.1s [CV] C=50, gamma=0.0005 .............................................. [CV] ................................ C=10, gamma=0.005, total= 0.1s [CV] C=50, gamma=0.001 ............................................... [CV] ................................ C=10, gamma=0.005, total= 0.1s [CV] C=10, gamma=0.005 ............................................... [CV] ................................. C=10, gamma=0.01, total= 0.1s [CV] C=50, gamma=0.0001 .............................................. [CV] ............................... C=50, gamma=0.0005, total= 0.1s [CV] C=50, gamma=0.0005 .............................................. [CV] ................................ C=50, gamma=0.001, total= 0.1s [CV] C=50, gamma=0.001 ............................................... [CV] ............................... C=50, gamma=0.0001, total= 0.1s [CV] ................................ C=10, gamma=0.005, total= 0.1s [CV] C=10, gamma=0.01 ................................................ [CV] ............................... C=50, gamma=0.0005, total= 0.1s [CV] C=50, gamma=0.0001 .............................................. [CV] C=50, gamma=0.0005 .............................................. [CV] ................................ C=50, gamma=0.001, total= 0.1s [CV] ................................. C=10, gamma=0.01, total= 0.1s [CV] C=10, gamma=0.01 ................................................ [CV] C=50, gamma=0.005 ............................................... [CV] ............................... C=50, gamma=0.0001, total= 0.1s [CV] C=50, gamma=0.0001 .............................................. [CV] ............................... C=50, gamma=0.0005, total= 0.1s [CV] C=50, gamma=0.001 ............................................... [CV] ................................. C=10, gamma=0.01, total= 0.1s [CV] ................................ C=50, gamma=0.005, total= 0.1s [CV] C=50, gamma=0.005 ............................................... [CV] C=50, gamma=0.005 ............................................... [CV] ............................... C=50, gamma=0.0001, total= 0.1s [CV] ................................ C=50, gamma=0.001, total= 0.1s [CV] ................................ C=50, gamma=0.005, total= 0.1s [CV] ................................ C=50, gamma=0.005, total= 0.1s [CV] C=50, gamma=0.01 ................................................ [CV] ................................. C=50, gamma=0.01, total= 0.0s [CV] C=50, gamma=0.01 ................................................ [CV] ................................. C=50, gamma=0.01, total= 0.0s [CV] C=50, gamma=0.01 ................................................ [CV] ................................. C=50, gamma=0.01, total= 0.0s Best parameters found by grid search: {'C': 10, 'gamma': 0.0005}[Parallel(n_jobs=4)]: Done 60 out of 60 | elapsed: 1.9s finished測試模型準確性
接著使用這一模型對測試集進行預測,并分別使用confusion_matrix和classification_report查看其效果
t = time() y_pred = clf.best_estimator_.predict(X_test_pca) cm = confusion_matrix(y_test, y_pred, labels=range(n_targets)) print("Done in {0:.2f}.\n".format(time()-t)) print("confusion matrix:") np.set_printoptions(threshold=np.nan) print(cm[:10]) Done in 0.01.confusion matrix: [[1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0][0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]] from sklearn.metrics import classification_report print(classification_report(y_test, y_pred, target_names=target_names)) #這里注意y_test和y_pred位置不要顛倒 precision recall f1-score supportp0 1.00 1.00 1.00 1p1 1.00 1.00 1.00 3p2 1.00 0.50 0.67 2p3 1.00 1.00 1.00 1p4 1.00 1.00 1.00 1p5 1.00 1.00 1.00 1p6 1.00 0.75 0.86 4p7 1.00 1.00 1.00 2p8 1.00 1.00 1.00 4p9 1.00 1.00 1.00 2p10 1.00 1.00 1.00 1p11 1.00 1.00 1.00 4p12 1.00 1.00 1.00 4p13 1.00 1.00 1.00 1p14 1.00 1.00 1.00 1p15 0.75 1.00 0.86 3p16 1.00 1.00 1.00 2p17 1.00 1.00 1.00 2p18 1.00 1.00 1.00 2p19 1.00 1.00 1.00 1p20 1.00 1.00 1.00 2p21 1.00 1.00 1.00 3p22 1.00 1.00 1.00 2p23 1.00 1.00 1.00 3p24 0.75 1.00 0.86 3p25 1.00 1.00 1.00 2p26 1.00 1.00 1.00 2p27 1.00 1.00 1.00 2p28 1.00 1.00 1.00 2p29 1.00 1.00 1.00 3p30 1.00 1.00 1.00 2p31 1.00 1.00 1.00 2p32 1.00 1.00 1.00 2p33 1.00 1.00 1.00 3p34 1.00 1.00 1.00 1p35 1.00 1.00 1.00 2p36 1.00 1.00 1.00 2avg / total 0.98 0.97 0.97 80/Users/hadoop/anaconda3/lib/python3.6/site-packages/sklearn/metrics/classification.py:1428: UserWarning: labels size, 37, does not match size of target_names, 40.format(len(labels), len(target_names))疑問:
效果非常樂觀,但是仍有個問題:怎么確定p0~p37分別對應的是哪個一個人?
總結
以上是生活随笔為你收集整理的PCA主成分分析+SVM实现人脸识别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 朴素贝叶斯--文档分类
- 下一篇: 使用aconda3-5.1.0(Pyth