scikit-learn にも顔照合の実装があることに気づいた。
scikit-learn Faces recognition example using eigenfaces and SVMs
使用しているデータベースは
Labeled Faces in the Wild
Deep Funnelingという手法で画像の正規化をしています。
~/scikit_learn_data/lfw_home/lfw_funneled
のディレクトリに人物ごとに別のフォルダに画像が収められています。
lfw_people = fetch_lfw_people(min_faces_per_person=70, resize=0.4)
として読み込んだlfw_peopleには
n_samples, h, w = lfw_people.images.shape
とあるように、画像の大きさがh, wとそろった画像がn_samples の枚数そろったものになっています。
n_classes: 6
とあり、6名が各クラスとなって識別をしています
lfw_people = fetch_lfw_people(min_faces_per_person=30, resize=0.4)
などとして、min_faces_per_personの値を変えると
分類する人の数が増えていきます。
タイトルのとおり、固有顔とSVMを用いている。
SVMを用いることで、固有顔のどの成分が識別に有効かどうかを判定していることになるのだと思う。
固有顔のいくつかは、照明変動のように、個人の識別に役に立たない成分です。
そのような成分は、SVMで分離性を上げるようにfit()したことで重みが低下しているのだろうと推測します。
顔照合の一般的な使い方とは違って
小規模の人数について区別することを行っています。
Ariel Sharon | 0.67 | 0.92 | 0.77 | 13 |
---|---|---|---|---|
Colin Powell | 0.75 | 0.78 | 0.76 | 60 |
Donald Rumsfeld | 0.78 | 0.67 | 0.72 | 27 |
George W Bush | 0.86 | 0.86 | 0.86 | 146 |
Gerhard Schroeder | 0.76 | 0.76 | 0.76 | 25 |
Hugo Chavez | 0.67 | 0.67 | 0.67 | 15 |
Tony Blair | 0.81 | 0.69 | 0.75 | 36 |
avg / total | 0.80 | 0.80 | 0.80 | 322 |
そのために、スクリプトを実行して表示される固有顔自体も、特定の人物たちの顔つきを反映しているように見えます。
(本当にそうかどうかは、未確認)
自分で、顔画像を登録したり、新たに撮影した顔画像を照合するには、顔画像を正規化する部分も実装しなくてはなりません。
以下の記事は、入力のデータベースの変更に関する質問です。
How to modify scikit-learn's eigenface face recognition example
The parameters data_home (give your path here!) and download_if_missing (unset it ie. provide False value for it) are there exactly for this purpose!
https://github.com/scikit-learn/scikit-learn/blob/14031f6/sklearn/datasets/lfw.py#L229
def fetch_lfw_people(data_home=None, funneled=True, resize=0.5,
min_faces_per_person=0, color=False,
slice_=(slice(70, 195), slice(78, 172)),
download_if_missing=True):
scikit-learn-examples-fork https://app.dominodatalab.com/u/marks/scikit-learn-examples-fork/view/.ipynb_checkpoints/Labeled+Faces+in+the+Wild+recognition-checkpoint.ipynb?commitId=f6ae6e0747392770773fbe649ff928ee214ab548