Daniil-Osokin / lightweight-human-pose-estimation-3d-demo.pytorch

Real-time 3D multi-person pose estimation demo in PyTorch. OpenVINO backend can be used for fast inference on CPU.
Apache License 2.0
656 stars 138 forks source link

How to Build module in MacOS #2

Closed simochen closed 4 years ago

simochen commented 4 years ago

A great work for 3d pose estimation! I found difficulties when build pose_extractor module in MacOS:

$ python setup.py build_ext
running build_ext
-- Configuring done
-- Generating done
-- Build files have been written to: /xxxxx/lightweight-human-pose-estimation-3d-demo.pytorch/pose_extractor/build/tmp
[100%] Built target pose_extractor
$ export PYTHONPATH=/xxxxx/lightweight-human-pose-estimation-3d-demo.pytorch/pose_extractor/build:$PYTHONPATH
$ python demo.py --model human-pose-estimation-3d.pth --video 0
Traceback (most recent call last):
  File "demo.py", line 10, in <module>
    from modules.parse_poses import parse_poses
  File "/xxxxx/lightweight-human-pose-estimation-3d-demo.pytorch/modules/parse_poses.py", line 4, in <module>
    from pose_extractor import extract_poses
ImportError: cannot import name 'extract_poses' from 'pose_extractor' (unknown location)

I also tried to import in python:

$ python
Python 3.7.3 (default, Mar 27 2019, 16:54:48)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pose_extractor
>>> from pose_extractor import parse_poses
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'parse_poses' from 'pose_extractor' (unknown location)
szmz commented 4 years ago

I have exactly the same issue.

Daniil-Osokin commented 4 years ago

Can you try to set one more environment variable:

export DYLD_LIBRARY_PATH=/xxxxx/lightweight-human-pose-estimation-3d-demo.pytorch/pose_extractor/build:$DYLD_LIBRARY_PATH

Will this help?

szmz commented 4 years ago

Unfortunately it doesn't help, I still get the same error:

ImportError: No module named pose_extractor

Although I have the pose_extractor.dylib file in pose_extractor/build folder, what is included in DYLD_LIBRARY_PATH

Thanks a lot: Zoltán Szegedy-Maszák

On Mon, Nov 11, 2019 at 7:46 PM Daniil-Osokin notifications@github.com wrote:

Can you try to set one more environment variable:

export DYLD_LIBRARY_PATH="/xxxxx/lightweight-human-pose-estimation-3d-demo.pytorch/pose_extractor/build:$DYLD_LIBRARY_PATH

Will this help?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Daniil-Osokin/lightweight-human-pose-estimation-3d-demo.pytorch/issues/2?email_source=notifications&email_token=AAYEYPUT5JLM2SBAXJWIN2TQTGR7LA5CNFSM4JLLTRZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDXXRFY#issuecomment-552564887, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYEYPTGMJ2SVNHKO26KPPTQTGR7LANCNFSM4JLLTRZQ .

Daniil-Osokin commented 4 years ago

Ok, this may be if different python versions used for build library and run demo script. Did you use virtualenv? I've pushed check_python branch, it has debug output for python version used to build library. Can you please compare it with one, used to run demo?

szmz commented 4 years ago

Thanks, I've tried with python 3.7:

python3 setup.py build_ext

running build_ext

Python executable: /usr/local/opt/python/bin/python3.7

Python libraries: /usr/local/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib

-- Configuring done

-- Generating done

-- Build files have been written to: /Users/szmz/Google Drive/work/python/Daniil-Osokin-lightweight-human-pose-estimation-3d-demo.pytorch-99a8291/pose_extractor/build/tmp

Scanning dependencies of target pose_extractor

[ 20%] Building CXX object CMakeFiles/pose_extractor.dir/wrapper.cpp.o

[ 40%] Linking CXX shared library ../pose_extractor.dylib

[100%] Built target pose_extractor

szmz@15MacBookPro Daniil-Osokin-lightweight-human-pose-estimation-3d-demo.pytorch-99a8291 %python3 demo.py --model human-pose-estimation-3d.xml --device CPU --use-openvino --video 0

Traceback (most recent call last):

File "demo.py", line 10, in

from modules.parse_poses import parse_poses

File "/Users/szmz/Google Drive/work/python/Daniil-Osokin-lightweight-human-pose-estimation-3d-demo.pytorch-99a8291/modules/parse_poses.py", line 4, in

from pose_extractor import extract_poses

ImportError: cannot import name 'extract_poses' from 'pose_extractor' (unknown location)

I only have python 2.5 as an alternative on this machine, which is unsuitable.

Thanks a lot: Zoltán

On Tue, Nov 12, 2019 at 6:51 PM Daniil-Osokin notifications@github.com wrote:

Ok, this may be if different python versions used for build library and run demo script. Did you use virtualenv? I've pushed check_python https://github.com/Daniil-Osokin/lightweight-human-pose-estimation-3d-demo.pytorch/tree/check_python branch, it has debug output https://github.com/Daniil-Osokin/lightweight-human-pose-estimation-3d-demo.pytorch/commit/3b82803ae374de8bbb784b10ca737171f8c86a9a#diff-38c714b36a1e14477a8ca46b76ce4caeR7 for python version used to build library. Can you please compare it with one, used to run demo?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Daniil-Osokin/lightweight-human-pose-estimation-3d-demo.pytorch/issues/2?email_source=notifications&email_token=AAYEYPWITO37UCU2XNFNMBTQTLUJDA5CNFSM4JLLTRZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED3ENZA#issuecomment-553010916, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYEYPTTGF2EWVBPL63FCZTQTLUJDANCNFSM4JLLTRZQ .

simochen commented 4 years ago

Ok, this may be if different python versions used for build library and run demo script. Did you use virtualenv? I've pushed check_python branch, it has debug output for python version used to build library. Can you please compare it with one, used to run demo?

I've tried to output the python version, and found it is the same as I used to run demo:

$ python setup.py build_ext
running build_ext
Python executable: /xxxxx/anaconda3/bin/python
Python libraries: /xxxxx/anaconda3/lib/libpython3.7m.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /xxxxx/lightweight-human-pose-estimation-3d-demo.pytorch/pose_extractor/build/tmp
[100%] Built target pose_extractor

The problem remains.

Daniil-Osokin commented 4 years ago

Hi guys, thanks for the checking! I've pushed one more commit to check_python branch, it changes suffix of library from .dylib to .so. Will this help?

simochen commented 4 years ago

Hi guys, thanks for the checking! I've pushed one more commit to check_python branch, it changes suffix of library from .dylib to .so. Will this help?

I found a new problem.

$ python demo.py --model human-pose-estimation-3d.pth --video 0 -d CPU
objc[26281]: Class CaptureDelegate is implemented in both /xxxxx/anaconda3/lib/python3.7/site-packages/cv2/cv2.cpython-37m-darwin.so (0x1157cd7e8) and /usr/local/opt/opencv/lib/libopencv_videoio.4.1.dylib (0x12ae73880). One of the two will be used. Which one is undefined.
Daniil-Osokin commented 4 years ago

Guys, specifically for you, I've installed virtual mac os on my very old laptop, all necessary packages (including xcode-tools, brew, etc.). Built OpenCV from source (since there are downloading on virtual mac os freezes for some reasons), built pose_extractor module (with provided fix, which sets .so suffix to library), added it to PYTHONPATH and ... it works. :shipit:

According to problem with multiple definitions, it says, that you have multiple OpenCV installations on your machine, and OS does not know, which implementation to use. It does not relate to this project, however suggest to leave just one OpenCV installation (remove second) to make things work. You may also try to run on an image, may be this will not cause similar error.

Daniil-Osokin commented 4 years ago

Hey, check it out! :bomb: Now it can run without c++ module.

szmz commented 4 years ago

Sorry, currently I'm on different machines/projects, but will come back as soon it is possible.

Best:Z

On Mon, Dec 2, 2019 at 7:44 PM Daniil-Osokin notifications@github.com wrote:

Hey, check it out! 💣 Now it can run without c++ module.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Daniil-Osokin/lightweight-human-pose-estimation-3d-demo.pytorch/issues/2?email_source=notifications&email_token=AAYEYPT7UZ6MUF7ESW3LV43QWVJR7A5CNFSM4JLLTRZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFUPNUQ#issuecomment-560527058, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYEYPUVN56ADZAI2NUVEC3QWVJR7ANCNFSM4JLLTRZQ .

Daniil-Osokin commented 4 years ago

Hope, it helped.