Home

Awesome

šŸ’ƒ Mobile 2D Single Person (Or Your Own Object) Pose Estimation for TensorFlow 2.0

This repository is forked from edvardHua/PoseEstimationForMobile when the original repository was closed. <br>edvardHua/PoseEstimationForMobile repository is reopened! I'll maintain it separately. šŸ‘

This repository currently implemented the Hourglass model using TensorFlow 2.0 with Keras API.

Table of contents

Goals

Getting Started

Install Anaconda (~10 min)

Create Virtual Environment (~2 min)

Create new environment.

conda create -n {env_name} python={python_version} anaconda
# in my case
# conda create -n mpe-env-tf2-alpha0 python=3.7 anaconda

Start the environment.

source activate {env_name}
# in my case
# source activate mpe-env-tf2-alpha0

Install the requirements (~1 min)

cd {tf2-mobile-pose-estimation_path}
pip install -r requirements.txt
pip install git+https://github.com/philferriere/cocoapi.git@2929bd2ef6b451054755dfd7ceb09278f935f7ad#subdirectory=PythonAPI
<details><summary>Download original COCO dataset.</summary> <p>

Download original COCO dataset

Special script that will help you to download and unpack needed COCO datasets. Please fill COCO_DATASET_PATH with path that is used in current version of repository. You can check needed path in file train.py

Warning Your system should have approximately 40gb of free space for datasets

python downloader.py --download-path=COCO_DATASET_PATH
</p> </details>

Run The Project

In order to use the project you have to:

  1. Prepare the dataset(ai_challenger dataset) and unzip.
  2. Run the model using:
python train.py \
--dataset_config config/dataset/coco_single_person_only-gpu.cfg \
--experiment_config config/training/coco_single_experiment01-cpm-sg4-gpu.cfg

Compatiable Datasets

Dataset NameDoanloadSizeNumber of images<br>train/validNumber of KeypointsNote
ai challengegoogle drive2GB22k/1.5k14default dataset of this repo
coco single person onlygoogle drive4GB25k/1k17filtered by showing only one person in an image which is from coco 2017 keypoint dataset

Results

AI Challenge Dataset

Model NameBackboneStage Or DepthPCH@.5SizeTotal EpochTotal Training TimeNote
MobileNetV2 based CPMcpm-b0Stage 1........Default CPM
MobileNetV2 based CPMcpm-b0Stage 2........
MobileNetV2 based CPMcpm-b0Stage 3........
MobileNetV2 based CPMcpm-b0Stage 4........
MobileNetV2 based CPMcpm-b0Stage 5........
MobileNetV2 based Hourglasshg-b0Depth 4........Default Hourglass

COCO Single persononly Dataset

Model NameBackboneStage Or DepthOKSSizeTotal EpochTotal Training TimeNote
MobileNetV2 based CPMcpm-b0Stage 1........Default CPM
MobileNetV2 based CPMcpm-b0Stage 2........
MobileNetV2 based CPMcpm-b0Stage 3........
MobileNetV2 based CPMcpm-b0Stage 4........
MobileNetV2 based CPMcpm-b0Stage 5........
MobileNetV2 based Hourglasshg-b0Depth 4........Default Hourglass

Converting To Mobile Model

TensorFLow Lite

If you train the model, it will create tflite models per evaluation step.

Core ML

Check convert_to_coreml.py script. The converted .mlmodel support iOS14+.

Details

This section will be separated to other .md file.

Folder Structure

tf2-mobile-pose-estimation
ā”œā”€ā”€ config
|   ā”œā”€ā”€ model_config.py
|   ā””ā”€ā”€ train_config.py
ā”œā”€ā”€ data_loader
|   ā”œā”€ā”€ data_loader.py
|   ā”œā”€ā”€ dataset_augment.py
|   ā”œā”€ā”€ dataset_prepare.py
|   ā””ā”€ā”€ pose_image_processor.py
ā”œā”€ā”€ models
|   ā”œā”€ā”€ common.py
|   ā”œā”€ā”€ mobilenet.py
|   ā”œā”€ā”€ mobilenetv2.py
|   ā”œā”€ā”€ mobilenetv3.py
|   ā”œā”€ā”€ resnet.py
|   ā”œā”€ā”€ resneta.py
|   ā”œā”€ā”€ resnetd.py
|   ā”œā”€ā”€ senet.py
|   ā”œā”€ā”€ simplepose_coco.py
|   ā””ā”€ā”€ simpleposemobile_coco.py
ā”œā”€ā”€ train.py            - the main training script
ā”œā”€ā”€ common.py 
ā”œā”€ā”€ requirements.txt
ā””ā”€ā”€ outputs             - this folder will be generated automatically when start training
    ā”œā”€ā”€ 20200312-sp-ai_challenger
    |   ā”œā”€ā”€ saved_model
    |   ā””ā”€ā”€ image_results
    ā””ā”€ā”€ 20200312-sp-ai_challenger
        ā””ā”€ā”€ ...

My SSD    
ā””ā”€ā”€ datasets            - this folder contains the datasets of the project.
    ā””ā”€ā”€ ai_challenger
        ā”œā”€ā”€ train.json
        ā”œā”€ā”€ valid.json
        ā”œā”€ā”€ train
        ā””ā”€ā”€ valid

TODO

Reference

[1] Paper of Convolutional Pose Machines <br/> [2] Paper of Stack Hourglass <br/> [3] Paper of MobileNet V2 <br/> [4] Repository PoseEstimation-CoreML <br/> [5] Repository of tf-pose-estimation <br> [6] Devlope guide of TensorFlow Lite <br/> [7] Mace documentation

Related Projects

Other Pose Estimation Projects

Contributing

This section will be separated to other .md file.

Any contributions are welcome including improving the project.

License

Apache License 2.0