Closed emilyemchen closed 2 years ago
Hi,
Can you try:
pip install opencv-python
Also, do you mind posting here the output when you do:
conda list
The reason is somehow cv2 was not installed in your case when you used the yml file, so I would like to investigate what went wrong. It indeed appears under the (pip) requirements and should have been installed using pip automatically (see here)
Hi,
Thanks for the quick reply!
I should have mentioned that I tried pip install opencv-python
and brew install opencv-python
too. I'm on a MacBook Pro (M1 chip) with macOS 11.6.7.
Here is the output from pip install opencv-python
:
Requirement already satisfied: opencv-python in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (4.6.0.66) Requirement already satisfied: numpy>=1.19.3 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from opencv-python) (1.21.3)
Here is the output for brew install opencv-python
:
Warning: No available formula with the name "opencv-python". Did you mean openvpn? ==> Searching for similarly named formulae... This similarly named formula was found: openvpn To install it, run: brew install openvpn ==> Searching for a previously deleted formula (in the last month)... Error: No previously deleted formula found. ==> Searching taps on GitHub... Error: No formulae found in taps.
Here is the output for conda list
when in env
:
packages in environment at miniconda3/envs/env:
Name Version Build Channel absl-py 0.15.0 pyhd3eb1b0_0 anaconda aiohttp 3.8.1 py38h1a28f6b_1 anaconda aiosignal 1.2.0 pyhd3eb1b0_0 anaconda async-timeout 4.0.1 pyhd3eb1b0_0 anaconda attrs 21.4.0 pyhd3eb1b0_0 anaconda blinker 1.4 py38hca03da5_0 anaconda bottleneck 1.3.4 py38heec5a64_0 anaconda brotli 1.0.7 hc377ac9_0 anaconda brotlipy 0.7.0 py38h1a28f6b_1002 anaconda bzip2 1.0.8 h620ffc9_4 anaconda c-ares 1.18.1 h1a28f6b_0 anaconda ca-certificates 2022.07.19 hca03da5_0
cachetools 4.2.2 pyhd3eb1b0_0 anaconda cairo 1.16.0 h29d4eff_2
certifi 2022.6.15 py38hca03da5_0
cffi 1.15.0 py38h22df2f2_1 anaconda charset-normalizer 2.0.4 pyhd3eb1b0_0 anaconda click 8.0.4 py38hca03da5_0 anaconda cryptography 3.4.7 py38h9dbe03d_0 anaconda cycler 0.11.0 pyhd3eb1b0_0 anaconda dataclasses 0.8 pyh6d0b6a4_7 anaconda eigen 3.4.0 hc021e02_0 conda-forge ffmpeg 4.2.2 h04105a8_0 anaconda ffmpeg-python 0.2.0 py_0 conda-forge fontconfig 2.13.94 heb65262_0 conda-forge fonttools 4.25.0 pyhd3eb1b0_0 anaconda freetype 2.11.0 h1192e45_0 anaconda frozenlist 1.2.0 py38h1a28f6b_0 anaconda future 0.18.2 py38hca03da5_1 anaconda gettext 0.21.0 h826f4ad_0 anaconda giflib 5.2.1 h1a28f6b_0 anaconda glib 2.69.1 h98b2900_1
gmp 6.2.1 hc377ac9_3 anaconda gnutls 3.6.15 h887c41c_0 anaconda google-auth 2.6.0 pyhd3eb1b0_0 anaconda google-auth-oauthlib 0.4.1 py_2 anaconda graphite2 1.3.14 hc377ac9_1
grpcio 1.42.0 py38h95c9599_0 anaconda gst-plugins-base 1.14.1 hf0a386a_0
gstreamer 1.14.1 he09cfb7_0
harfbuzz 4.3.0 hb1b0ec1_0
hdf5 1.12.1 nompi_had0e5e0_103 conda-forge icu 68.1 hc377ac9_0 anaconda idna 3.3 pyhd3eb1b0_0 anaconda importlib-metadata 4.11.3 py38hca03da5_0 anaconda iniconfig 1.1.1 pyhd3eb1b0_0 anaconda joblib 1.1.0 pyhd3eb1b0_0 anaconda jpeg 9e h1a28f6b_0 anaconda kiwisolver 1.4.2 py38hc377ac9_0 anaconda krb5 1.19.2 h3b8d789_0
lame 3.100 h1a28f6b_0 anaconda lcms2 2.12 hba8e193_0 anaconda libblas 3.9.0 15_osxarm64_openblas conda-forge libcblas 3.9.0 15_osxarm64_openblas conda-forge libclang 12.0.0 default_hc321e17_4
libcurl 7.84.0 hc6d1d07_0
libcxx 12.0.0 hf6beb65_1 anaconda libedit 3.1.20210910 h1a28f6b_0
libev 4.33 h642e427_1 conda-forge libffi 3.4.2 hc377ac9_4 anaconda libgfortran 5.0.0 11_2_0_he6877d6_26 anaconda libgfortran5 11.2.0 he6877d6_26 anaconda libiconv 1.16 h1a28f6b_2 anaconda libidn2 2.3.1 h1a28f6b_0 anaconda liblapack 3.9.0 15_osxarm64_openblas conda-forge libllvm12 12.0.1 h93073aa_2 conda-forge libnghttp2 1.46.0 h95c9599_0
libopenblas 0.3.20 hea475bc_0 anaconda libopus 1.3 h1a28f6b_1 anaconda libpng 1.6.37 hb8d0fd4_0 anaconda libpq 12.9 h65cfe13_3
libprotobuf 3.20.1 h98b2900_0 anaconda libssh2 1.10.0 hb80f160_3 conda-forge libtasn1 4.16.0 h1a28f6b_0 anaconda libtiff 4.2.0 h01837e1_1 anaconda libunistring 0.9.10 h1a28f6b_0 anaconda libvpx 1.10.0 hc377ac9_0 anaconda libwebp 1.2.2 h68602c7_0 anaconda libwebp-base 1.2.2 h1a28f6b_0 anaconda libxml2 2.9.14 h8c5e841_0 anaconda libxslt 1.1.35 h9833966_0
libzlib 1.2.12 ha287fd2_2 conda-forge littleutils 0.2.2 py_0 conda-forge llvm-openmp 12.0.0 haf9daa7_1 anaconda lz4-c 1.9.3 hc377ac9_0 anaconda markdown 3.3.4 py38hca03da5_0 anaconda matplotlib 3.5.0 py38hca03da5_0 anaconda matplotlib-base 3.5.0 py38h9197a36_0 anaconda mpmath 1.2.1 py38hca03da5_0 anaconda multidict 5.2.0 py38h1a28f6b_2 anaconda munkres 1.1.4 py_0 anaconda ncurses 6.3 h1a28f6b_2 anaconda nettle 3.7.3 h84b5d62_1 anaconda nspr 4.33 hc377ac9_0
nss 3.74 h142855e_0
numexpr 2.8.1 py38h144ceef_2 anaconda numpy 1.23.3 pypi_0 pypi oauthlib 3.2.0 pyhd3eb1b0_0 anaconda opencv 4.5.5 py38h8794c10_4
opencv-python 4.6.0.66 pypi_0 pypi openh264 1.8.0 h98b2900_0 anaconda openssl 1.1.1q h1a28f6b_0
outdated 0.2.1 pyhd8ed1ab_0 conda-forge packaging 21.3 pyhd3eb1b0_0 anaconda pandas 1.3.5 py38h9197a36_0 anaconda pandas-flavor 0.2.0 py_0 conda-forge patsy 0.5.2 py38hca03da5_1 anaconda pcre 8.45 hbdafb3b_0 conda-forge pillow 9.0.1 py38h4d1bdd5_0 anaconda pingouin 0.5.2 pyhd8ed1ab_0 conda-forge pip 21.2.4 py38hca03da5_0 anaconda pixman 0.40.0 h27ca646_0 conda-forge pluggy 1.0.0 py38hca03da5_1 anaconda protobuf 3.20.1 py38hc377ac9_0 anaconda py 1.11.0 pyhd3eb1b0_0 anaconda pyasn1 0.4.8 pyhd3eb1b0_0 anaconda pyasn1-modules 0.2.8 py_0 anaconda pycparser 2.21 pyhd3eb1b0_0 anaconda pyjwt 2.1.0 py38hca03da5_0 anaconda pyopenssl 21.0.0 pyhd3eb1b0_1 anaconda pyparsing 3.0.4 pyhd3eb1b0_0 anaconda pysocks 1.7.1 py38hca03da5_0 anaconda pytest 7.1.2 py38hca03da5_0 anaconda python 3.8.13 hbdb9e5c_0 anaconda python-dateutil 2.8.2 pyhd3eb1b0_0 anaconda python_abi 3.8 2_cp38 conda-forge pytorch 1.12.1 py3.8_0 pytorch pytz 2022.1 py38hca03da5_0 anaconda qt-main 5.15.2 ha2d02b5_4
qt-webengine 5.15.9 h2903aaf_4
qtwebkit 5.212 h0f11f3c_4
readline 8.1.2 h1a28f6b_1 anaconda requests 2.27.1 pyhd3eb1b0_0 anaconda requests-oauthlib 1.3.0 py_0 anaconda rsa 4.7.2 pyhd3eb1b0_1 anaconda scikit-learn 1.0.2 py38h9197a36_1 anaconda scipy 1.7.1 py38hd0c9ec0_0 conda-forge seaborn 0.11.2 pyhd3eb1b0_0 anaconda setuptools 61.2.0 py38hca03da5_0 anaconda six 1.16.0 pyhd3eb1b0_1 anaconda sqlite 3.38.5 h1058600_0 anaconda statsmodels 0.13.0 py38h1a28f6b_0 anaconda tabulate 0.8.9 py38hca03da5_0 anaconda tensorboard 2.6.0 py_1 anaconda tensorboard-data-server 0.6.0 py38h10d4710_0 conda-forge tensorboard-plugin-wit 1.6.0 py_0 anaconda threadpoolctl 2.2.0 pyh0d69192_0 anaconda tk 8.6.12 hb8d0fd4_0 anaconda tomli 1.2.2 pyhd3eb1b0_0 anaconda torchvision 0.13.1 py38_cpu pytorch tornado 6.1 py38h1a28f6b_0 anaconda tqdm 4.64.0 py38hca03da5_0 anaconda typing-extensions 4.1.1 hd3eb1b0_0 anaconda typing_extensions 4.1.1 pyh06a4308_0 anaconda urllib3 1.26.9 py38hca03da5_0 anaconda werkzeug 2.0.3 pyhd3eb1b0_0 anaconda wheel 0.37.1 pyhd3eb1b0_0 anaconda x264 1!152.20180806 h1a28f6b_0 anaconda xarray 0.20.1 pyhd3eb1b0_1 anaconda xz 5.2.5 h1a28f6b_1 anaconda yarl 1.6.3 py38h1a28f6b_1 anaconda zipp 3.8.0 py38hca03da5_0 anaconda zlib 1.2.12 h5a0b063_2 anaconda zstd 1.5.2 h8574219_0 anaconda
Can you try to just:
python -c "import cv2"
does it throw any error? is your conda environment active? (did you activate it ?)
Yes, my conda environment is active. Just tried python -c "import cv2"
and got this error:
Traceback (most recent call last): File "
", line 1, in ImportError: No module named cv2
Also, I just tried commenting out the first line of "test.py" and then it had the same error for the next module the script is trying to import (PIL). So it might be an issue that is larger than just cv2:
Traceback (most recent call last): File "test.py", line 2, in
from PIL import Image ImportError: No module named PIL
Yes, my conda environment is active. Just tried python -c "import cv2" and got this error:
so it seems like the environment is not set up correctly, because even a plain python import doesn't work.
what does python --version
output?
Also to be absolutely positive, can you print out what you get from:
echo $CONDA_DEFAULT_ENV
and
echo $CONDA_PREFIX
do you get what you expect? (i.e. a path to the conda environment that you created)
I noticed now that there are multiple opencv installations in the same environment you created. Can you remove this env and create a new one (using the environment.yml file) and print out the output from conda list
again?
opencv strictly prohibits multiple installations of the package in the same environment
last note: you might need to use this fix since M1 chips don't work with newer torchvision versions
Hi @yoterel -- I am from the same lab as @emilyemchen. To make things simpler for ourselves, we produced a docker image of the icatcher_plus environment/dependencies -- see my other issue here: #8 for more info. This works as a solution to @emilyemchen 's problems so this issue could be closed
Thanks for the great documentation! I'm having trouble running the Step 4 command, as I'm getting the following error:
This is the command I'm running (replacing the actual string to my directories with [PATHTO]):
python test.py [PATHTO]/icatcher_plus/models/icatcher+_lookit.pth --fc_model [PATHTO]/icatcher_plus/models/face_classifier_lookit_weights_best.pt --output_video_path [PATH TO ANNOTATED VIDEOS] --output_annotation [PATH TO ANNOTATIONS] --show_output
My environment.yml file is up to date (e.g., using python 3.9).
I've tried
conda install opencv-python
andconda install opencv
. Neither has worked.Any other suggestions that might help resolve this issue?