• Stars
    star
    664
  • Rank 65,411 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

The example project of inferencing Pose Estimation using Core ML

logo-pose-estimatiton-for-coreml-3

platform-ios swift-version lisence

This project is Pose Estimation on iOS with Core ML.
If you are interested in iOS + Machine Learning, visit here you can see various DEMOs.

ํ•œ๊ตญ์–ด README

Jointed Keypoints Hatmaps Still Image

Video source:

Pose Capturing Pose Matching

Features

  • Estimate body pose on a image
  • Inference with camera's pixel buffer on real-time
  • Inference with a photo library's image
  • Visualize as heatmaps
  • Visualize as lines and points
  • Pose capturing and pose matching

How it works

how_it_works

Requirements

  • Xcode 9.2+
  • iOS 11.0+
  • Swift 4

Model

Get PoseEstimationForMobile's model

Download this temporary models from following link.

Or

โ˜ž Download Core ML model model_cpm.mlmodel or hourglass.mlmodel.

input_name_shape_dict = {"image:0":[1,192,192,3]} image_input_names=["image:0"]
output_feature_names = ['Convolutional_Pose_Machine/stage_5_out:0']

๏ผin https://github.com/tucan9389/pose-estimation-for-mobile

Model Size, Minimum iOS Version, Input/Output Shape

Model Size
(MB)
Minimum
iOS Version
Input Shape Output Shape
cpm 2.6 iOS11 [1, 192, 192, 3] [1, 96, 96, 14]
hourhglass 2 iOS11 [1, 192, 192, 3] [1, 48, 48, 14]

Infernece Time (ms)

Model vs. Device 11
Pro
XS
Max
XR X 8 8+ 7 7+ 6S+ 6+
cpm 5 27 27 32 31 31 39 37 44 115
hourhglass 3 6 7 29 31 32 37 42 48 94

mobile-pose-estimation

Total Time (ms)

Model vs. Device 11
Pro
XS
Max
XR X 8 8+ 7 7+ 6S+ 6+
cpm 23 39 40 46 47 45 55 58 56 139
hourhglass 23 15 15 38 40 40 48 55 58 106

FPS

Model vs. Device 11
Pro
XS
Max
XR X 8 8+ 7 7+ 6S+ 6+
cpm 15 23 23 20 20 21 17 16 16 6
hourhglass 15 23 23 24 23 23 19 16 15 8

Get your own model

Or you can use your own PoseEstimation model

Build & Run

1. Prerequisites

1.1 Import pose estimation model

๋ชจ๋ธ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ.png

Once you import the model, compiler generates model helper class on build path automatically. You can access the model through model helper class by creating an instance, not through build path.

1.2 Add permission in info.plist for device's camera access

prerequest_001_plist

2. Dependencies

No external library yet.

3. Code

3.1 Import Vision framework

import Vision

3.2 Define properties for Core ML

// properties on ViewController
typealias EstimationModel = model_cpm // model name(model_cpm) must be equal with mlmodel file name
var request: VNCoreMLRequest!
var visionModel: VNCoreMLModel!

3.3 Configure and prepare the model

override func viewDidLoad() {
    super.viewDidLoad()

    visionModel = try? VNCoreMLModel(for: EstimationModel().model)
	request = VNCoreMLRequest(model: visionModel, completionHandler: visionRequestDidComplete)
	request.imageCropAndScaleOption = .scaleFill
}

func visionRequestDidComplete(request: VNRequest, error: Error?) {
    /* ------------------------------------------------------ */
    /* something postprocessing what you want after inference */
    /* ------------------------------------------------------ */
}

3.4 Inference ๐Ÿƒโ€โ™‚๏ธ

// on the inference point
let handler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer)
try? handler.perform([request])

Performance Test

1. Import the model

You can download cpm or hourglass model for Core ML from tucan9389/pose-estimation-for-mobile repo.

2. Fix the model name on PoseEstimation_CoreMLTests.swift

3. Run the test

Hit the โŒ˜ + U or click the Build for Testing icon.

See also

More Repositories

1

awesome-ml-demos-with-ios

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

SemanticSegmentation-CoreML

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

ObjectDetection-CoreML

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

tf2-mobile-2d-single-pose-estimation

๐Ÿ’ƒ Pose estimation for iOS and android using TensorFlow 2.0
Python
167
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