cansik / mediapipe-silicon

Prebuilt Google MediaPipe packages for arm64.
MIT License
77 stars 4 forks source link

error downloading and running mediapipe on M1 #10

Open AlecSkril opened 1 year ago

AlecSkril commented 1 year ago

Hi @cansik, I am trying to use mediapipe and opencv on my M1 Mac. I got opencv to run perfectly fine but cannot download mediapipe. I have tried mediapipe-silicon both brew and pip3.9 installations and no luck. They are installed globally with Vscode's editor correctly configured and I cannot get mediapipe to run. I am getting three different errors.

objc[17276]: Class CaptureDelegate is implemented in both /opt/homebrew/lib/python3.9/site-packages/cv2/cv2.abi3.so (0x124eda840) and /opt/homebrew/lib/python3.9/site-packages/mediapipe/.dylibs/libopencv_videoio.3.4.16.dylib (0x120bbc860). One of the two will be used. Which one is undefined.
objc[17276]: Class CVWindow is implemented in both /opt/homebrew/lib/python3.9/site-packages/cv2/cv2.abi3.so (0x124eda890) and /opt/homebrew/lib/python3.9/site-packages/mediapipe/.dylibs/libopencv_highgui.3.4.16.dylib (0x11f0dca68). One of the two will be used. Which one is undefined.
objc[17276]: Class CVView is implemented in both /opt/homebrew/lib/python3.9/site-packages/cv2/cv2.abi3.so (0x124eda8b8) and /opt/homebrew/lib/python3.9/site-packages/mediapipe/.dylibs/libopencv_highgui.3.4.16.dylib (0x11f0dca90). One of the two will be used. Which one is undefined.

The second error:

ImportError: dlopen(/Users/alecskriloff/Library/Python/3.9/lib/python/site-packages/PIL/_imaging.cpython-39-darwin.so, 0x0002): tried: '/Users/alecskriloff/Library/Python/3.9/lib/python/site-packages/PIL/_imaging.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/alecskriloff/Library/Python/3.9/lib/python/site-packages/PIL/_imaging.cpython-39-darwin.so' (no such file), '/Users/alecskriloff/Library/Python/3.9/lib/python/site-packages/PIL/_imaging.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

I have tried virtual environments, different python versions, and spoke with many people about this issue. And this is the weird thing...I have run this exact code before on my machine and it worked perfectly fine. I must have changed something or a file got corrupted because whatever I do I cannot get mediapipe to work. Any suggestions would be greatly appreciated!

M1 Max, Ventura 13.2, python 3.9 and Vscode IDE. I have pasted a screenshot to my error below. Screenshot 2023-02-01 at 8 50 00 PM

cansik commented 1 year ago

Hi @AlecSkril, the first messages are warnings, not errors, as already described in #4.

Second, it seems that you are mixing Rosetta2 python (Intel) and M1 python (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')). Please setup a new clean environment, only using python for Apple Silicon and try it again.

AlecSkril commented 1 year ago

Hi @AlecSkril, the first messages are warnings, not errors, as already described in #4.

Second, it seems that you are mixing Rosetta2 python (Intel) and M1 python (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')). Please setup a new clean environment, only using python for Apple Silicon and try it again.

Thank you for your help. I was able to fix it and get it to run properly. I changed something, not exactly sure what, and now I am getting an AttibuteError for mp.solutions.drawing_utils. I am trying to figure it out now. Any suggestions on how I could fix this? Also, I am trying to use the pose estimation .tflite heavy model and can't seem to get it to work. Is there documentation on using the mediapipe .tflite models? Thanks for all your help.

cansik commented 1 year ago

To be honest «not exactly sure what» is not a great way to fix problems. Because of that I can not really tell you why it does not work to access the mp.solutions.drawing_utils. On the systems I tried, everything seems to work. First, make a clean install of python (for example with homebrew) and install mediapipe-silicon. If the problem still exists, please attach the error message and describe the way how you installed everything.