• Stars
    star
    167
  • Rank 218,979 (Top 5 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ’ƒ Pose estimation for iOS and android using TensorFlow 2.0

๐Ÿ’ƒ 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.
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

  • ๐Ÿ“š Easy to train
  • ๐Ÿƒโ€ Easy to use the model on mobile device

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
Download original COCO dataset.

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

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 Name Doanload Size Number of images
train/valid
Number of Keypoints Note
ai challenge google drive 2GB 22k/1.5k 14 default dataset of this repo
coco single person only google drive 4GB 25k/1k 17 filtered by showing only one person in an image which is from coco 2017 keypoint dataset
  • ai challenge's keypoint names: ['top_head', 'neck', 'left_shoulder', 'right_shoulder', 'left_elbow', 'right_elbow', 'left_wrist', 'right_wrist', 'left_hip', 'right_hip', 'left_knee', 'right_knee', 'left_ankle', 'right_ankle']
  • coco's keypoint names: ['nose', 'left_eye', 'right_eye', 'left_ear', 'right_ear', 'left_shoulder', 'right_shoulder', 'left_elbow', 'right_elbow', 'left_wrist', 'right_wrist', 'left_hip', 'right_hip', 'left_knee', 'right_knee', 'left_ankle', 'right_ankle']

Results

AI Challenge Dataset

Model Name Backbone Stage Or Depth [email protected] Size Total Epoch Total Training Time Note
MobileNetV2 based CPM cpm-b0 Stage 1 .. .. .. .. Default CPM
MobileNetV2 based CPM cpm-b0 Stage 2 .. .. .. ..
MobileNetV2 based CPM cpm-b0 Stage 3 .. .. .. ..
MobileNetV2 based CPM cpm-b0 Stage 4 .. .. .. ..
MobileNetV2 based CPM cpm-b0 Stage 5 .. .. .. ..
MobileNetV2 based Hourglass hg-b0 Depth 4 .. .. .. .. Default Hourglass

COCO Single persononly Dataset

Model Name Backbone Stage Or Depth OKS Size Total Epoch Total Training Time Note
MobileNetV2 based CPM cpm-b0 Stage 1 .. .. .. .. Default CPM
MobileNetV2 based CPM cpm-b0 Stage 2 .. .. .. ..
MobileNetV2 based CPM cpm-b0 Stage 3 .. .. .. ..
MobileNetV2 based CPM cpm-b0 Stage 4 .. .. .. ..
MobileNetV2 based CPM cpm-b0 Stage 5 .. .. .. ..
MobileNetV2 based Hourglass hg-b0 Depth 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

  • Save model to saved_model
  • Convert the model(saved_model) to TFLite model(.tflite)
  • Convert the model(saved_model) to Core ML model(.mlmodel)
  • Run the model on iOS
  • Release 1.0 models
  • Support distributed GPUs training
  • Make DEMO gif running on mobile device
  • Run the model on Android

Reference

[1] Paper of Convolutional Pose Machines
[2] Paper of Stack Hourglass
[3] Paper of MobileNet V2
[4] Repository PoseEstimation-CoreML
[5] Repository of tf-pose-estimation
[6] Devlope guide of TensorFlow Lite
[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

More Repositories

1

awesome-ml-demos-with-ios

The challenge projects for Inferencing machine learning models on iOS
Python
1,133
star
2

PoseEstimation-CoreML

The example project of inferencing Pose Estimation using Core ML
Swift
664
star
3

SemanticSegmentation-CoreML

The example project of inferencing Semantic Segementation using Core ML
Swift
296
star
4

ObjectDetection-CoreML

An example running Object Detection using Core ML (YOLOv8, YOLOv5, YOLOv3, MobileNetV2+SSDLite)
Swift
253
star
5

PoseEstimation-TFLiteSwift

The baseline project for inferencing various Pose Estimation tflite models with TFLiteSwift on iOS
Swift
144
star
6

DepthPrediction-CoreML

The example of running Depth Prediction using Core ML
Swift
131
star
7

TextRecognition-MLKit

Swift
85
star
8

TextDetection-CoreML

Swift
74
star
9

FingertipEstimation-CoreML

Detect fingertip by using machine learning for pose estimation
Swift
70
star
10

KeypointAnnotation

Swift
42
star
11

TFLiteSwift-Vision

Swift
36
star
12

ImageClassification-CoreML

The example of running Image Classification using Core ML
Swift
31
star
13

FaceDetection-MLKit

Swift
20
star
14

PoseEstimation-MLKit

The example of running Pose Estimation using ML Kit
Swift
17
star
15

SimpleClassification-CreateML-CoreML

Create ML๋กœ ๋‚˜๋งŒ์˜ Classifier ๋ชจ๋ธ์„ ๋งŒ๋“ค๊ณ  Core ML๋กœ ์•ฑ์—์„œ ์‚ฌ์šฉํ•ด๋ณด๋Š” End-to-End ์˜ˆ์ œ ํ”„๋กœ์ ํŠธ์ž…๋‹ˆ๋‹ค.
Swift
13
star
16

InstanceSegmentation-CoreML

Swift
11
star
17

MobileNet-MLKit

MLKit์„ ์‚ฌ์šฉํ•˜์—ฌ MobileNet.tflite๋ฅผ ์‹คํ–‰์‹œ์ผœ๋ณธ ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.
Swift
9
star
18

GyroMaze-STM32

์ž„๋ฒ ๋””๋“œ ์‹คํ—˜์—์„œ ํ…€ ํ”„๋กœ์ ํŠธ ๊ฒฐ๊ณผ๋ฌผ์ž…๋‹ˆ๋‹ค.
C
7
star
19

pytorch-Korean-NER

Python
5
star
20

HangeulClock-iOS

Objective-C
5
star
21

MNIST-TFLiteSwift

Swift
4
star
22

MyBookshelf-iOS

The assignment is to see code design, code accuracy, data structure, algorithms, and learning abilities, as well as the ability to implement your app.
Objective-C
4
star
23

excel-example-ios

libxlsxwriter(C๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ)๋ฅผ iOS์—์„œ ์‚ฌ์šฉํ•œ ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.
Swift
4
star
24

image-clustering-browser

Python
3
star
25

WordRecognition-CoreML-MLKit

Detect character, find a word what I point and then recognize the word using Core ML and ML Kit.
3
star
26

ZoomableScrollView

Simple Zoomable Scroll View inherited from UIScrollView
Swift
3
star
27

tc-stock-management-system

1
star
28

async-filtering-photo-album-ios

Swift
1
star
29

MLProblem-MLFramework-for-iOS-template-project

Swift
1
star
30

tucan9389.github.io

HTML
1
star
31

mnist-ml-to-mobile

Python
1
star