sign-language-processing / pose

Library for viewing, augmenting, and handling .pose files
https://pose-format.readthedocs.io/en/latest/
MIT License
73 stars 23 forks source link

ModuleNotFoundError: No module named 'cv2' (and also mediapipe) #111

Open cleong110 opened 3 weeks ago

cleong110 commented 3 weeks ago

Error:

When running videos_to_poses as described in the README on a fresh machine I got this:

videos_to_poses --format mediapipe --directory videos/
Traceback (most recent call last):
  File "/home/vlab/miniconda3/envs/signsegment/bin/videos_to_poses", line 5, in <module>
    from pose_format.bin.directory import main
  File "/home/vlab/miniconda3/envs/signsegment/lib/python3.12/site-packages/pose_format/bin/directory.py", line 4, in <module>
    from pose_format.bin.pose_estimation import pose_video
  File "/home/vlab/miniconda3/envs/signsegment/lib/python3.12/site-packages/pose_format/bin/pose_estimation.py", line 5, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

Steps to replicate:

conda create -n signsegment pip
conda activate signsegment
pip install pose-format
videos_to_poses --format mediapipe --directory videos/

System info

System info: image

Package versions

Output of conda after env creation: image

Output of pip list:

pip list
Package     Version
----------- -------
numpy       2.1.0
pip         24.2
pose_format 0.6.0
scipy       1.14.1
setuptools  72.1.0
tqdm        4.66.5
wheel       0.43.0

Fix, and further error "please install mediapipe":

$ pip install opencv-python
Collecting opencv-python
  Using cached opencv_python-4.10.0.84-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (20 kB)
Requirement already satisfied: numpy>=1.21.2 in /home/vlab/miniconda3/envs/signsegment/lib/python3.12/site-packages (from opencv-python) (2.1.0)
Using cached opencv_python-4.10.0.84-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (62.5 MB)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.10.0.84
$ $ videos_to_poses --format mediapipe --directory videos/
Traceback (most recent call last):
  File "/home/vlab/miniconda3/envs/signsegment/lib/python3.12/site-packages/pose_format/utils/holistic.py", line 10, in <module>
    import mediapipe as mp
ModuleNotFoundError: No module named 'mediapipe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/vlab/miniconda3/envs/signsegment/bin/videos_to_poses", line 5, in <module>
    from pose_format.bin.directory import main
  File "/home/vlab/miniconda3/envs/signsegment/lib/python3.12/site-packages/pose_format/bin/directory.py", line 4, in <module>
    from pose_format.bin.pose_estimation import pose_video
  File "/home/vlab/miniconda3/envs/signsegment/lib/python3.12/site-packages/pose_format/bin/pose_estimation.py", line 6, in <module>
    from pose_format.utils.holistic import load_holistic
  File "/home/vlab/miniconda3/envs/signsegment/lib/python3.12/site-packages/pose_format/utils/holistic.py", line 12, in <module>
    raise ImportError("Please install mediapipe with: pip install mediapipe")
ImportError: Please install mediapipe with: pip install mediapipe

pip install mediapipe then fixed that error, and videos_to_poses ran well

AmitMY commented 3 weeks ago

The idea is that pose-format is lightweight. It does not require many libraries to parse and save pose files, but if you want to visualize or estimate, there needs to be more installation. We try to alert the user with ImportError: Please install mediapipe with: pip install mediapipe

cleong110 commented 1 week ago

Interesting! Maybe we could add them as optional dependencies so people can do something like pip install [visualize]?

hmm... I saw a library that did that once, langcodes. https://pypi.org/project/langcodes/. When I looked into it further it seems you need to add optional dependencies to the .toml (source)... and there is already a dev target...!

Perhaps simply adding something to the README would solve the problem then.

AmitMY commented 2 days ago

Easy to add it here same as here