Pythonの軽量な顔認識・顔属性分析フレームワーク・ライブラリ「deepface」をインストールする

Pythonの軽量な顔認識・顔属性分析フレームワーク・ライブラリ「deepface」をインストールしてみます。

deepface(ディープフェイス)は、Python用の軽量な顔認識および顔属性分析(年齢、性別、感情、人種)フレームワークです。ライブラリのベースは、主にKerasとTensorFlow。またVGG-Face, Google FaceNet, OpenFace, Facebook DeepFace, DeepID, ArcFace,Dlibなどの最新モデルを搭載。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■deepfaceをインストールする

deepfaceをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install deepface

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。

py -3.8 -m pip install deepface

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting deepface
Downloading deepface-0.0.67-py3-none-any.whl (61 kB)
|████████████████████████████████| 61 kB 488 kB/s
Requirement already satisfied: pandas>=0.23.4 in c:\users\user_\appdata\roaming\python\python38\site-packages (from deepface) (1.2.4)
Collecting mtcnn>=0.1.0
Downloading mtcnn-0.1.1-py3-none-any.whl (2.3 MB)
|████████████████████████████████| 2.3 MB 1.3 MB/s
Requirement already satisfied: Pillow>=5.2.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from deepface) (8.2.0)
Collecting tensorflow>=1.9.0
Downloading tensorflow-2.5.0-cp38-cp38-win_amd64.whl (422.6 MB)
|████████████████████████████████| 422.6 MB 6.6 kB/s
Requirement already satisfied: tqdm>=4.30.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from deepface) (4.61.1)
Collecting Flask>=1.1.2
Downloading Flask-2.0.1-py3-none-any.whl (94 kB)
|████████████████████████████████| 94 kB 1.4 MB/s
Collecting gdown>=3.10.1
Downloading gdown-3.13.0.tar.gz (9.3 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: opencv-python>=3.4.4 in c:\users\user_\appdata\roaming\python\python38\site-packages (from deepface) (4.5.2.54)
Collecting keras>=2.2.0
Downloading Keras-2.4.3-py2.py3-none-any.whl (36 kB)
Requirement already satisfied: numpy>=1.14.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from deepface) (1.20.3)
Collecting retina-face>=0.0.1
Downloading retina_face-0.0.5-py3-none-any.whl (14 kB)
Requirement already satisfied: pytz>=2017.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from pandas>=0.23.4->deepface) (2021.1)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from pandas>=0.23.4->deepface) (2.8.1)
Collecting h5py~=3.1.0
Downloading h5py-3.1.0-cp38-cp38-win_amd64.whl (2.7 MB)
|████████████████████████████████| 2.7 MB 3.3 MB/s
Collecting typing-extensions~=3.7.4
Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting wheel~=0.35
Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Collecting grpcio~=1.34.0
Downloading grpcio-1.34.1-cp38-cp38-win_amd64.whl (2.9 MB)
|████████████████████████████████| 2.9 MB 3.2 MB/s
Collecting flatbuffers~=1.12.0
Downloading flatbuffers-1.12-py2.py3-none-any.whl (15 kB)
Collecting absl-py~=0.10
Downloading absl_py-0.13.0-py3-none-any.whl (132 kB)
|████████████████████████████████| 132 kB 3.3 MB/s
Collecting keras-preprocessing~=1.1.2
Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 540 kB/s
Collecting wrapt~=1.12.1
Downloading wrapt-1.12.1.tar.gz (27 kB)
Collecting astunparse~=1.6.3
Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Collecting tensorflow-estimator<2.6.0,>=2.5.0rc0
Downloading tensorflow_estimator-2.5.0-py2.py3-none-any.whl (462 kB)
|████████████████████████████████| 462 kB 6.4 MB/s
Requirement already satisfied: protobuf>=3.9.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from tensorflow>=1.9.0->deepface) (3.17.3)
Collecting six~=1.15.0
Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting tensorboard~=2.5
Downloading tensorboard-2.5.0-py3-none-any.whl (6.0 MB)
|████████████████████████████████| 6.0 MB 6.8 MB/s
Collecting gast==0.4.0
Downloading gast-0.4.0-py3-none-any.whl (9.8 kB)
Collecting opt-einsum~=3.3.0
Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)
|████████████████████████████████| 65 kB 4.8 MB/s
Collecting keras-nightly~=2.5.0.dev
Downloading keras_nightly-2.5.0.dev2021032900-py2.py3-none-any.whl (1.2 MB)
|████████████████████████████████| 1.2 MB 3.3 MB/s
Collecting termcolor~=1.1.0
Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Collecting google-pasta~=0.2
Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
|████████████████████████████████| 57 kB 1.1 MB/s
Collecting Werkzeug>=2.0
Downloading Werkzeug-2.0.1-py3-none-any.whl (288 kB)
|████████████████████████████████| 288 kB 6.4 MB/s
Requirement already satisfied: click>=7.1.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from Flask>=1.1.2->deepface) (7.1.2)
Collecting itsdangerous>=2.0
Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
Requirement already satisfied: Jinja2>=3.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from Flask>=1.1.2->deepface) (3.0.1)
Collecting filelock
Downloading filelock-3.0.12-py3-none-any.whl (7.6 kB)
Requirement already satisfied: requests[socks]>=2.12.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from gdown>=3.10.1->deepface) (2.25.1)
Requirement already satisfied: pyyaml in c:\users\user_\appdata\roaming\python\python38\site-packages (from keras>=2.2.0->deepface) (5.4.1)
Requirement already satisfied: scipy>=0.14 in c:\users\user_\appdata\roaming\python\python38\site-packages (from keras>=2.2.0->deepface) (1.7.0)
Collecting google-auth-oauthlib<0.5,>=0.4.1
Downloading google_auth_oauthlib-0.4.5-py2.py3-none-any.whl (18 kB)
Collecting markdown>=2.6.8
Downloading Markdown-3.3.4-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 2.3 MB/s
Requirement already satisfied: google-auth<2,>=1.6.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from tensorboard~=2.5->tensorflow>=1.9.0->deepface) (1.32.1)
Requirement already satisfied: setuptools>=41.0.0 in c:\program files\python38\lib\site-packages (from tensorboard~=2.5->tensorflow>=1.9.0->deepface) (47.1.0)
Collecting tensorboard-plugin-wit>=1.6.0
Downloading tensorboard_plugin_wit-1.8.0-py3-none-any.whl (781 kB)
|████████████████████████████████| 781 kB 3.3 MB/s
Collecting tensorboard-data-server<0.7.0,>=0.6.0
Downloading tensorboard_data_server-0.6.1-py3-none-any.whl (2.4 kB)
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from Jinja2>=3.0->Flask>=1.1.2->deepface) (2.0.1)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests[socks]>=2.12.0->gdown>=3.10.1->deepface) (2021.5.30)
Requirement already satisfied: idna<3,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests[socks]>=2.12.0->gdown>=3.10.1->deepface) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests[socks]>=2.12.0->gdown>=3.10.1->deepface) (1.26.5)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests[socks]>=2.12.0->gdown>=3.10.1->deepface) (4.0.0)
Requirement already satisfied: PySocks!=1.5.7,>=1.5.6; extra == "socks" in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests[socks]>=2.12.0->gdown>=3.10.1->deepface) (1.7.1)
Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.5->tensorflow>=1.9.0->deepface) (1.3.0)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow>=1.9.0->deepface) (4.2.2)
Requirement already satisfied: rsa<5,>=3.1.4; python_version >= "3.6" in c:\users\user_\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow>=1.9.0->deepface) (4.7.2)
Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow>=1.9.0->deepface) (0.2.8)
Requirement already satisfied: oauthlib>=3.0.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.5->tensorflow>=1.9.0->deepface) (3.1.1)
Requirement already satisfied: pyasn1>=0.1.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from rsa<5,>=3.1.4; python_version >= "3.6"->google-auth<2,>=1.6.3->tensorboard~=2.5->tensorflow>=1.9.0->deepface) (0.4.8)
Using legacy setup.py install for wrapt, since package 'wheel' is not installed.
Using legacy setup.py install for termcolor, since package 'wheel' is not installed.
Building wheels for collected packages: gdown
Building wheel for gdown (PEP 517) ... done
Created wheel for gdown: filename=gdown-3.13.0-py3-none-any.whl size=9034 sha256=eb00ba5d116b5150e149df04484c04ea8fbf3f687310d8de43cbc6c069a25cef
Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\04\51\53\ed3e97af28b242e9eb81afb4836273fbe233a14228aa82fea3
Successfully built gdown
ERROR: tensorflow 2.5.0 has requirement numpy~=1.19.2, but you'll have numpy 1.20.3 which is incompatible.
Installing collected packages: h5py, keras, mtcnn, typing-extensions, wheel, six, grpcio, flatbuffers, absl-py, keras-preprocessing, wrapt, astunparse, tensorflow-estimator, google-auth-oauthlib, Werkzeug, markdown, tensorboard-plugin-wit, tensorboard-data-server, tensorboard, gast, opt-einsum, keras-nightly, termcolor, google-pasta, tensorflow, itsdangerous, Flask, filelock, gdown, retina-face, deepface
Attempting uninstall: typing-extensions
Found existing installation: typing-extensions 3.10.0.0
Uninstalling typing-extensions-3.10.0.0:
Successfully uninstalled typing-extensions-3.10.0.0
Attempting uninstall: six
Found existing installation: six 1.16.0
Uninstalling six-1.16.0:
Successfully uninstalled six-1.16.0
Attempting uninstall: grpcio
Found existing installation: grpcio 1.38.1
Uninstalling grpcio-1.38.1:
Successfully uninstalled grpcio-1.38.1
Running setup.py install for wrapt ... done
Running setup.py install for termcolor ... done
Successfully installed Flask-2.0.1 Werkzeug-2.0.1 absl-py-0.13.0 astunparse-1.6.3 deepface-0.0.67 filelock-3.0.12 flatbuffers-1.12 gast-0.4.0 gdown-3.13.0 google-auth-oauthlib-0.4.5 google-pasta-0.2.0 grpcio-1.34.1 h5py-3.1.0 itsdangerous-2.0.1 keras-2.4.3 keras-nightly-2.5.0.dev2021032900 keras-preprocessing-1.1.2 markdown-3.3.4 mtcnn-0.1.1 opt-einsum-3.3.0 retina-face-0.0.5 six-1.15.0 tensorboard-2.5.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.0 tensorflow-2.5.0 tensorflow-estimator-2.5.0 termcolor-1.1.0 typing-extensions-3.7.4.3 wheel-0.36.2 wrapt-1.12.1
WARNING: You are using pip version 20.1.1; however, version 21.2.1 is available.
You should consider upgrading via the 'C:\Program Files\Python38\python.exe -m pip install --upgrade pip' command.

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、deepfaceが正常にインストールされたことになります。

なお、今回はdeepfaceのバージョン0.0.67をインストールしました。

ちなみに、今回インストールを行うと、「ERROR: tensorflow 2.5.0 has requirement numpy~=1.19.2, but you’ll have numpy 1.20.3 which is incompatible.」というエラーが発生。deepfaceのベースとなるtensorflowのバージョン2.5.0はnumpyモジュールの1.19.2を要求していますが、互換性のないnumpyモジュールのバージョン1.20.3を使用という内容なので、numpyをアンインストールし、バージョンを変更した方が良い。

バージョンを変更せずに、「ERROR: tensorflow 2.5.0 has requirement numpy~=1.19.2, but you’ll have numpy 1.20.3 which is incompatible.」というエラーが発生した状態で、顔の表情の検出してみましたが、検出することができました。

コメント

タイトルとURLをコピーしました