画像認識・機械学習のライブラリdlibで顔位置の画像を取り出そうとして
ある状況で次のようにつまづいた。
備忘録としてメモを残す。
トラブルの内容
$ python
Python 2.7.12 (default, Nov 20 2017, 18:23:56)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>> dlib.get_face_chips
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'get_face_chips'
>>> dlib.__version__
'19.7.0'
>>> dlib.__file__
'/usr/local/lib/python2.7/dist-packages/dlib/__init__.pyc'
>>>
ちなみに、
dlibをgit clone した次のディレクトリでは問題を発生していない。
()/dlib/python_examples$
()/dlib/python_examples$ ./face_alignment.py shape_predictor_5_face_landmarks.dat ../examples/faces/bald_guys.jpg
()/dlib/python_examples$ python
Python 2.7.12 (default, Nov 20 2017, 18:23:56)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>> dlib.get_face_chips
<Boost.Python.function object at 0x1d3d0b0>
>>> dlib.__version__
'19.7.99'
>>> dlib.__file__
'dlib.so'
>>>
dlib をgit clone したディレクトリでの
$ sudo python setup.py install
だけでは不十分だった。
/usr/local/lib/python2.7/dist-packages$ echo dlib*
dlib dlib-19.7.0-py2.7.egg-info dlib-19.7.99-py2.7-linux-x86_64.egg
の中で、19.7.99の版だけ残して
dlib dlib-19.7.0-py2.7.egg-info
の2つをなくしてから
$ source ~/.bashrc
をすると解決した。
別な手法でインストールしたdlibが残っていて、その版にはget_face_chips()が含まれていなかったためと判明した。
付記
http://dlib.net/python/index.html
には
get_face_chips
get_face_chip
の記述はない。バージョンの違いによることだったのだろう。