[Python] I tried using OpenPose

Introduction

I didn't use this article because it was a discussion about using Openpose when I did it in the image hackathon I experienced, so I wanted to study it. In addition, I performed face recognition in Making a cat detector using OpenCV, which I posted so far, and studied whole body authentication and labeling in I tried using YOLOv3. This time I studied skeleton detection, so I will keep it as a record. Please take a look at the articles mentioned above! (20201221-5)

The article I referred to is here. [TensorFlow version] OpenPose (compatible with osx Mojave) on MacBook

What is Openpose

OpenPose is a tool that allows you to easily display the skeleton of a person without motion capture. Macbook users have a built-in camera, so they can also draw real-time videos. This time I will try to perform skeleton detection on the image.

When executed, such an image will be created. openpose.png

In this way, it is possible to embed something like a stick figure with skeletons connected in an image and output it. This can also be done with a video, so I'd like to try it next time.

Installation and installation

Environment

First, install anaconda, which is used to create a virtual environment. Since anaconda is very convenient when using python, please check anaconda and install it if you have not installed it.

$ conda create -n pose python=3.6 anaconda

Next, let's enter the created virtual environment.

$ source activate pose

When you enter the virtual environment, the command will change as follows.

(pose) $

If this happens, use cd to move to the directory you want to work in.

Next, clone from github and drop the repository used this time locally.

(pose) $ git clone https://github.com/ildoonet/tf-pose-estimation

Enter the file cloned on github with cd tf-pose-estimation.

Installation of required modules

Then install the required modules.

(pose) $ pip install -r requirements.txt
(pose) $ pip install matplotlib
(pose) $ brew install swig
(pose) $ pip install numpy cython tensorflow==1.15.0 opencv-python

Up to this point, the environment has been installed and installed.

Download the required files with cmu

Go to the hierarchy called cmu with cd models/graph/cmu

(pose) $ bash download.sh

Install the required files with the above command. In addition, change directory to ~/tf-pose-estimation/tf_pose/pafprocess /.

(pose) $ swig -python -c++ pafprocess.i && python3 setup.py build_ext --inplace
(pose) $ sudo python setup.py build_ext --inplace

This is the end of setup. I didn't get an error, but some people do. The corrective action for those who have an error is described in detail in Reference article, so I will omit it. Let's do it! !!

Run

Let's do it!

Move the directory to run.

(pose) $ cd tf-pose-estimation/src

Let's do it!

Executes a still image

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

An image called p1.jpg was included as a sample. p1.jpg is here p1.jpg

I tried to do that this time. The result of the execution is shown in the figure below. スクリーンショット 2020-12-20 15.49.53.png

In this way, it seems that it will output 4 types together, such as an image with a skeleton embedded in a color image and an image with a scale scale.

It's very interesting!

I tried skeleton detection, but I learned that there is gait authentication as an application. Gait authentication is said to distinguish people by looking at their "walking style." It is said that the way of walking is completely different depending on the person, and it seems that the authentication method to grasp the characteristics is also awkward. Next time, I would like to see gait certification!

I am very happy to be able to implement the model that was on the agenda at the hackathon I participated in and to absorb more of the hackathon experience.

Thank you for reading this far! Thank you for following and LGTM! Also, I am still studying, so please feel free to ask any questions, advice, or suggestions!

============================================= ~ List of articles posted in the past ~ [Image system] Making a cat detector with Google Colabratory (Part 1) [Python] ~ About scraping ~ Making a cat detector with Google Colabratory (Part 2) [Python] ~ Using OpenCV ~ [Python] I tried using YOLO v3

[Natural language processing] Classification of data using natural language processing

===============================================

reference [TensorFlow version] OpenPose (compatible with osx Mojave) performed on MacBook Install and run OpenPose on Mac (https://qiita.com/mml/items/8c24a5acc5f2d71b1df4)

Recommended Posts

[Python] I tried using OpenPose
I tried using Thonny (Python / IDE)
I tried shooting Kamehameha using OpenPose
[Python] I tried using YOLO v3
I tried using parameterized
I tried using argparse
I tried using mimesis
I tried using aiomysql
I tried using Summpy
I tried Python> autopep8
I tried using Pipenv
I tried using Bayesian Optimization in Python
I tried using matplotlib
I tried using ESPCN
I tried using openpyxl
I tried using UnityCloudBuild API from Python
I tried using Ipython
I tried using PyCaret
I tried using cron
I tried using ngrok
I tried using face_recognition
I tried using Jupyter
I tried using PyCaret
I tried using Heapq
I tried using doctest
I tried Python> decorator
I tried using folium
I tried using jinja2
I tried using folium
I tried using time-window
vprof --I tried using the profiler for Python
I tried web scraping using python and selenium
I tried object detection using Python and OpenCV
I tried using mecab with python2.7, ruby2.3, php7
I tried reading a CSV file using Python
I tried fp-growth with python
I tried scraping with Python
[I tried using Pythonista 3] Introduction
I tried using easydict (memo).
I tried face recognition using Face ++
I tried using Random Forest
I tried using BigQuery ML
I tried using Amazon Glacier
I tried using git inspector
I tried Python C extension
I tried using magenta / TensorFlow
I tried gRPC with Python
I tried scraping with python
I tried using AWS Chalice
I tried using Slack emojinator
[Python] I immediately tried using Pylance's VS Code extension.
I tried using TradeWave (BitCoin system trading in Python)
[Python] I tried running a local server using flask
I tried drawing a pseudo fractal figure using Python
I tried using Python (3) instead of a scientific calculator
I tried to access Google Spread Sheets using Python
I tried to touch Python (installation)
I tried web scraping with python.
I tried using Rotrics Dex Arm
I tried using GrabCut of OpenCV
I tried Grumpy (Go running Python).