Pose Estimation with TensorFlow 2.0

Gunjan Sethi
2 min readApr 8, 2020

--

Here’s a quick tutorial on how to install, setup and test the Tensorflow 2.0 implementation of OpenPose on the macOS.

Please install Anaconda/Miniconda. I’m using Miniconda3. Here’s a link to the docs: https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html

We’re going to use the tweaked version of this amazing library. I have upgraded the code for Tensorflow 2.0 compatibility: https://github.com/gsethi2409/tf-pose-estimation

If you prefer a video tutorial, find it here-

Let’s get started!

Step 1: Create a new virtual environment
conda create — name AIMachine

Step 2: Activate your virtual environment
conda activate AIMachine

Step 3: Install Python
conda install python==3.7.6

Step 4: Install the latest version of Tensorflow
conda install tensorflow
Optional reading: https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/

Step 5: Create a new working directory and go into the folder.
mkdir myWorkspace
cd myWorkspace

Step 6: Clone the pose estimation repository.

git clone https://github.com/gsethi2409/tf-pose-estimation.git

Step 7: Enter the folder and install the requirements.

cd tf-pose-estimationpip install -r requirements.txt

Step 8: Install SWIG

conda install swig

Step 9: Build C++ library for post-processing.

cd tf_pose/pafprocessswig -python -c++ pafprocess.i && python3 setup.py build_ext --inplace

Step 10: Install OpenCV.

pip install opencv-python

Step 11: Install tf-slim library.

pip install git+https://github.com/adrianc-a/tf-slim.git@remove_contrib

Step 12: Download Tensorflow Graph File(pb file).

cd models/graph/cmubash download.shcd ../../..

Step 13: Run a quick test!

python run.py --model=mobilenet_thin --resize=432x368 --image=./images/p1.jpg

Step 14: Run a webcam test!

python run_webcam.py --model=mobilenet_thin --resize=432x368 --camera=0

--

--