Trouble Installing OpenFace in Python - python

I am new to deeplearning and face recognition. After searching, I found this python package about deeplearning applied to face recognition called OpenFace. From its documentation, I think it is build on top of Torch for the neural nets computation.
I want to install the package in a virtual environment, so basically these are steps I made:
brew install the necessary system requirements: bash,coreutils,curl,findutils,opencv, python and boost-python
Make a virtual environment and install dlib, numpy, scipy, pandas, scikit-learn, scikit-image
Cloned the openface github repository
Install Torch
curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
git clone https://github.com/torch/distro.git torch --recursive
cd torch
./install.sh
source install/bin/torch-activate
luarocks install csvigo
luarocks install dpnn
luarocks install nn
cd to cloned openface repo and run
python setup.py install
However when I run python:
>>>import openface
I get:
Segmentation Fault: 11
How do I fix this? Also, are there any other tutorials for using openface?
How to properly install OpenFace?

As I posted in the comments, this segfault was caused by compiling dlib with one Python version and running it with another. This was resolved by manually installing dlib rather than using their pip package.

I installed dlib with pip for openface and had no problem importing it for Python 2.7:
[jalal#goku scratch]$ sudo /usr/bin/pip install dlib
[sudo] password for jalal:
Collecting dlib
Downloading dlib-19.7.0.tar.gz (4.0MB)
100% |████████████████████████████████| 4.0MB 347kB/s
Installing collected packages: dlib
▽
Running setup.py install for dlib ... done
Successfully installed dlib-19.7.0
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Related

ModuleNotFoundError: No module named 'Cython' even though Cython is installed in Azure Devops

I'm setting up some CI/CD for a Python app (Azure Function) using Azure Devops and I've stumbled upon an issue with one of the requirements. The error I receive is ModuleNotFoundError: No module named 'Cython' while trying to install pymssql-2.1.4. Before this requirement, I have set a Cython==0.29.21 to be installed and it is installed as it can be seen through out the logs as
Collecting Cython==0.29.21
Downloading Cython-0.29.21-cp38-cp38-manylinux1_x86_64.whl (1.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9/1.9 MB 73.5 MB/s eta 0:00:00
I'm not sure why this error happens, I did some research and saw that it can be a problem with the pip version so I update the pip before doing the installation but the error keeps persisting. This is my yaml code for the part where I install the requirements.
python3 -m venv worker_venv
source worker_venv/bin/activate
python3 -m pip install pip --upgrade
pip3 install setuptools
pip3 install -r requirements.txt
I use python 3.8 version and ubuntu 20.04. Does somebody know how can I fix this?
I managed to solve it myself. In my case, for pymssql-2.1.4, I downgraded python to 3.7, downgraded pip to 20.0.2 and manually install cython before running the pip install -r requirements.txt. My new yaml now looks like
python3 -m venv worker_venv
source worker_venv/bin/activate
pip3 install pip==20.0.2
pip3 install --upgrade setuptools
pip3 install --upgrade cython
pip3 install -r requirements.txt
This did fix the problem and I no longer struggle with this kind of error. Posting this in case someone finds it useful

Python, pip install stuck on collecting "module_name"

Using freshly installed python 3.5.2 on windows 10, trying to install libraries via cmd, gives such result:
C:\Python35>pip install theano
Collecting theano
C:\Python35>pip install numpy
Collecting numpy
C:\Python35>pip list
pip (8.1.1)
setuptools (20.10.1)
C:\Python35>
The question is simple, how to make pip to install?
About trial and error. I did try to find solution, yes, and here is what does not work:
Using --no-cache-dir
pip install numpy-1.16.1-cp37-cp37m-win_amd64.whl same for Theano
python -m pip install and every special combination of parameters like pip3 -vvv and so on.
manually deleted the contents of the cache directory
ran as administrator, launched cmd from python folder
reinstalled python, restarted pc, have internet connection

Installing YOLOv5 dependencies - torchvision?

I want to use yolov5. According to https://pytorch.org/hub/ultralytics_yolov5/, you should have Python>=3.8 and PyTorch>=1.7 installed, as well as YOLOv5 dependencies.
Python and pytorch are up to date:
pip show torch
Version: 1.7.1
python --version
Python 3.9.1
But when I try to install the yolov5 dependencies, I get an error message:
pip install -qr https://raw.githubusercontent.com/ultralytics/yolov5/master/requirements.txt
ERROR: Could not find a version that satisfies the requirement torchvision>=0.8.1
ERROR: No matching distribution found for torchvision>=0.8.1
An updated version of torchvision is needed (???). So I run the update, but when I check the version it hasn't worked.
pip show torchvision
Version: 0.2.2.post3
-m pip install --upgrade torchvision
pip show torchvision
Version: 0.2.2.post3
Is torchvision needed for installing the yolov5 dependencies? How do I move forward? I'm on Windows 10.
Thanks!
I was getting similar error. Installing fresh compatible libraries (torch==1.7.1 & torchvision==0.8.2) worked for me.
virtualenv -p python3.8 torch17
source torch17/bin/activate
pip install cython matplotlib tqdm scipy ipython ninja yacs opencv-python ffmpeg opencv-contrib-python Pillow scikit-image scikit-learn lmfit imutils pyyaml jupyterlab==3
pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
Be careful about your cuda version and install accordingly. Mine is 10.1. Simply using pip install torch==1.7.1 will install latest cuda version (11) compatible lib which might not be your case.
Virtual environment activation command will be different for Windows. I am on Linux

python-Levenshtein library install error on MacOS

I am trying to install a package on a python project but having some issues with python-Levenshtein library. I'm using a virtual environment on PyCharm which is running with Python3.8 and installed all libraries in requirements.txt with pip. However I am not able to install this library.
What I've tried so far:
try to install with pip and pip3
try to install with anaconda
try to install with brew (to make sure it's not like matplotlib here)
I share the error message below. Could you help me to solve this problem
Collecting python-Levenshtein==0.12.0
Using cached python-Levenshtein-0.12.0.tar.gz (48 kB)
Requirement already satisfied: setuptools in /Users/suleyman/Projects/venv/lib/python3.8/site-packages (from python-Levenshtein==0.12.0) (51.1.1)
Building wheels for collected packages: python-Levenshtein
Building wheel for python-Levenshtein (setup.py): started
Building wheel for python-Levenshtein (setup.py): finished with status 'error'
Running setup.py clean for python-Levenshtein
Failed to build python-Levenshtein
Installing collected packages: python-Levenshtein
Running setup.py install for python-Levenshtein: started
Running setup.py install for python-Levenshtein: finished with status 'error'
ERROR: Command errored out with exit status 1:
You can just do python3 -m pip install python-levenshtein or if you want to install system-wide just do the sudo -H python3 -m pip install python-levenshtein.
P.S. It works for me.
I've found the solution and explain it for those who suffers from the same thing. Macbook comes with its own python in usr/bin/python and user/bin/python3 and first I used them as base interpreter however I faced that issue. I think default pythons don't include some essentials.
The solution is installing your python and giving its path as the base interpreter. After that pip is able to install the library.
That solved my issue and I am able to install my libraries.
Try installing libpython3.8-dev (see this post)
I was running into the same build error on Ubuntu 18.04 until I ran
sudo apt install libpython3.8-dev
Then, inside my python virtual environment, I ran
python3 -m pip install python-Levenshtein
If that doesn't work, check that you have build-essential installed. If not, then try:
sudo apt install build-essential

anaconda dlib and X11

I am on a mac os X Yosemite. I installed dlib with anaconda with:
conda install -c menpo dlib=19.4
and then removed X11 from anaconda/lib since the X11 distributed by anaconda is presumably broken. Then I installed Xquartz from https://www.xquartz.org/.
But when I go into ipython and import dlib, and type
dlib.image_window()
I am still getting error:
AttributeError: 'module' object has no attribute 'image_window'
What's the issue?
Note I tried installing dlib from scratch when anaconda is not in my system, and I ran into all kinds of other issues. So currently I am committed to making dlib work with anaconda, which it does, except for image_window and presumably other things associated with X11.
I ran into the same issue on my Mac. After doing readings on GitHub, I don't think there exists a workaround for installing dlib with anaconda, since something is not right with X11 headers used by anaconda.
I am able to make dlib.image_window() work after building dlib from source using the latest version available on the repo. The steps are large the same as suggested here on GitHub. The following steps were carried out in a conda environment I use exclusively for computer vision applications:
Clean up dlib installed via conda:
conda uninstall dlib
Install cmake and boost-bython with homebrew:
brew install cmake
brew install boost-python
Build dlib from source:
git clone https://github.com/davisking/dlib.git
cd dlib/
mkdir build
cd build/
cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1; cmake --build .
python setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA
The codes took a while to build, but the library works for me in the end.

Categories

Resources