日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > pytorch >内容正文

pytorch

ML之SVM:调用(sklearn的lfw_people函数在线下载55个外国人图片文件夹数据集)来精确实现人脸识别并提取人脸特征向量

發布時間:2025/3/21 pytorch 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ML之SVM:调用(sklearn的lfw_people函数在线下载55个外国人图片文件夹数据集)来精确实现人脸识别并提取人脸特征向量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ML之SVM:調用(sklearn的lfw_people函數在線下載55個外國人圖片文件夾數據集)來精確實現人臉識別并提取人臉特征向量

?

?

?

目錄

輸出結果

代碼設計


?

?

?

輸出結果

?

?

代碼設計

from __future__ import print_function from time import time import logging import matplotlib.pyplot as plt from sklearn.cross_validation import train_test_split from sklearn.datasets import fetch_lfw_people from sklearn.grid_search import GridSearchCV from sklearn.metrics import classification_report from sklearn.metrics import confusion_matrix from sklearn.decomposition import RandomizedPCA from sklearn.svm import SVC print(__doc__)logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') ###############################################################################lfw_people = fetch_lfw_people(min_faces_per_person=99, resize=0.4) n_samples, h, w = lfw_people.images.shape X = lfw_people.data n_features = X.shape[1] y = lfw_people.target target_names = lfw_people.target_names n_classes = target_names.shape[0] print("Total dataset size:") print("n_samples: %d" % n_samples) print("n_features: %d" % n_features) print("n_classes: %d" % n_classes) ###############################################################################X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)############################################################################### n_components = 150 print("Extracting the top %d eigenfaces from %d faces"% (n_components, X_train.shape[0])) t0 = time() pca = RandomizedPCA(n_components=n_components, whiten=True).fit(X_train) print("done in %0.3fs" % (time() - t0))eigenfaces = pca.components_.reshape((n_components, h, w)) print("Projecting the input data on the eigenfaces orthonormal basis") t0 = time() X_train_pca = pca.transform(X_train) X_test_pca = pca.transform(X_test) print("done in %0.3fs" % (time() - t0))############################################################################### print("Fitting the classifier to the training set") t0 = time() param_grid = {'C': [1e3, 5e3, 1e4, 5e4, 1e5],'gamma': [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.1], }clf = GridSearchCV(SVC(kernel='rbf', class_weight='balanced'), param_grid) #auto改為balancedclf = clf.fit(X_train_pca, y_train) print("done in %0.3fs" % (time() - t0)) print("Best estimator found by grid search:") print(clf.best_estimator_) ############################################################################### print("Predicting people's names on the test set") t0 = time() y_pred = clf.predict(X_test_pca) print("done in %0.3fs" % (time() - t0))print(classification_report(y_test, y_pred, target_names=target_names)) print(confusion_matrix(y_test, y_pred, labels=range(n_classes)))def plot_gallery(images, titles, h, w, n_row=3, n_col=4):"""Helper function to plot a gallery of portraits""" plt.figure(figsize=(1.8 * n_col, 2.4 * n_row)) plt.subplots_adjust(bottom=0, left=.01, right=.99, top=.90, hspace=.35)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], size=12)plt.xticks(())plt.yticks(())def title(y_pred, y_test, target_names, i): pred_name = target_names[y_pred[i]].rsplit(' ', 1)[-1]true_name = target_names[y_test[i]].rsplit(' ', 1)[-1]return 'predicted: %s\ntrue: %s' % (pred_name, true_name)prediction_titles = [title(y_pred, y_test, target_names, i) for i in range(y_pred.shape[0])]plot_gallery(X_test, prediction_titles, h, w) eigenface_titles = ["eigenface %d" % i for i in range(eigenfaces.shape[0])] plot_gallery(eigenfaces, eigenface_titles, h, w) plt.show()

?

相關文章
ML之SVM:調用(sklearn的lfw_people函數在線下載55個外國人圖片文件夾數據集)來精確實現人臉識別并提取人臉特征向量

總結

以上是生活随笔為你收集整理的ML之SVM:调用(sklearn的lfw_people函数在线下载55个外国人图片文件夹数据集)来精确实现人脸识别并提取人脸特征向量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 38在线视频 | 日韩一区二区视频在线播放 | 色欲色香天天天综合网www | 国产精品成人网站 | 超碰狠狠| 性xxxx视频| 激情的网站 | 亚洲国产免费视频 | 日韩在线第三页 | 亚洲一区二区在线播放 | 他揉捏她两乳不停呻吟动态图 | 天天综合网天天综合色 | 国产精品美女毛片真酒店 | av毛片在线看 | 在线国产视频一区 | 青青草午夜 | 黄色一级大片在线观看 | 日本aⅴ在线观看 | 在线国产小视频 | 欧美日本日韩 | www视频在线观看 | 国产精品无人区 | 90岁肥老奶奶毛毛外套 | 日韩欧美xxx | 欧美片一区二区三区 | 一区二区三区视频在线观看免费 | 秘密基地在线观看完整版免费 | 另类少妇人与禽zozz0性伦 | 国产a国产片国产 | 日韩精品人妻中文字幕有码 | www.国产视频.com | 国产精品美女久久久 | 亚洲精品乱码久久久久久蜜桃不卡 | 日本www黄 | 91污网站 | 国产一区不卡在线观看 | 美女扒开屁股让男人捅 | 中文字幕+乱码+中文字幕一区 | 天堂va在线 | 日本xxxx高清| 欧美cccc极品丰满hd | 免费精品无码AV片在线观看黄 | 国内精品视频在线播放 | 什么网站可以看毛片 | 浓精h攵女乱爱av | 色一情一区二区三区 | 99超碰在线观看 | 色哟哟免费在线观看 | 天天操夜夜摸 | 日韩美女三级 | 第一av在线 | 久久国产亚洲精品无码 | 国产精品一二三级 | 国产精品久久久一区二区 | 精品黑人一区二区三区 | 久草最新网址 | 久久综合区 | 丁香花电影高清在线阅读免费 | 大尺度摸揉捏胸床戏视频 | 亚洲男女av | 久久久69| a v视频在线播放 | 精品动漫一区二区三区在线观看 | 国产第4页 | 久久国产美女 | 亚洲人成网站999久久久综合 | 亚洲第一天堂影院 | 婷婷另类小说 | 免费毛片在线播放 | 国产主播福利在线 | 亚洲啪av永久无码精品放毛片 | 中文天堂资源在线 | 日韩在线视频在线观看 | 国产亚洲综合在线 | 国产成人精品视频在线 | 天天影视亚洲 | 国产精品美女久久久久久 | 91精品国产欧美一区二区 | 欧美一级黄色大片 | 一进一出好爽视频 | 国产69精品久久久久久久 | 成人黄色录像 | 国产精品视频一区二区三区不卡 | 欧美区日韩区 | 哺乳援交吃奶在线播放 | 色咪咪网站 | 国产精品美女久久久久久 | 中文字幕一区二区三区5566 | 在线观看欧美一区二区三区 | 中文字幕一区二区在线视频 | 国产一区不卡在线 | 久久曰视频 | 亚洲欧美在线看 | 污视频网址 | 嫩草免费视频 | 欧美黑人粗大 | 免费av网站在线 | 麻豆国产91在线播放 | 国产欧美在线视频 |