YuvalNirkin/face_swap

"No module named face_swap_py", when I use python interface

hao-qiang opened this issue · 2 comments

Hello Yuval,
You do an excellent job in face swap. And I have a question when invoking python interface after compiling.

import face_swap_py as fspy

I do this at the path of 'face_swap_py.pyd' but it report error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named face_swap_py

It also doesn't work after adding
"export PYTHONPATH=/home/hq/project/face_swap_YuvalNirkin/interfaces/python:$PYTHONPATH" in "~/.bashrc" file.

Could you give me some advices, thanks a lot.
Johnson

Hello Johnson,
There was a bug with the python binding in Linux (a native module can only be loaded if it has the extension ".so"). It's fixed now, please git pull the changes and rebuild.

Also I changed the recommended way to install the library on Ubuntu:

  • Make sure you have installed Boost 1.65.1 or newer.
  • It's better to build a static version of the face swap library with -DBUILD_SHARED_LIBS=OFF.
  • Add "export PYTHONPATH=$PYTHONPATH:~/installations/face_swap/interfaces/python" to ~/.profile.

I have updated the Ubuntu installation guide with those changes.

Let me know if it works for you now.

Thanks for helping me find this bug,
Yuval

Thanks a lot, it works very well. : )