Skip to content

Commit 55d8e67

Browse files
committed
Initial commit
0 parents  commit 55d8e67

File tree

129 files changed

+3134
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+3134
-0
lines changed

README.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Human Pose Estimation usign Deep Neural Network
2+
3+
4+
This demo shows how to train and test a human pose estimation using deep neural network. In R2019b, Deep Learning Toolbox(TM) supports low-level APIs to customize training loops and it enables us to train flexible deep neural networks. GPU Coder(TM) also enables us to deploy the trained model to an NVIDIA(R) Jetson(TM) devices. Once deployed, the human pose estimator will be running as a standalone.
5+
6+
7+
8+
9+
This repository includes a pretrained network using the COCO dataset, which was collected by the COCO Consortium (cocodataset.org).
10+
11+
12+
13+
# Required Toolboxes
14+
15+
16+
Pose Estimation Toolbox requires the following products:
17+
18+
19+
20+
- MATLAB(R) R2019b or later (due to the R2019b new feature)
21+
- [Deep Learning Toolbox(TM)](https://mathworks.com/products/deep-learning.html)
22+
- [Image Processing Toolbox(TM)](https://mathworks.com/products/image.html)
23+
- [Computer Vision Toolbox(TM)](https://www.mathworks.com/products/computer-vision.html)
24+
- [Parallel Computing Toolbox(TM)](https://mathworks.com/products/parallel-computing.html) (Required for using GPU computation)
25+
26+
27+
28+
To deploy the model to a NVIDIA Jetson or Drive platforms, you'll also need the following products.
29+
30+
31+
32+
- [MATLAB Coder(TM)](https://mathworks.com/products/matlab-coder.html)
33+
- [GPU Cder(TM)](https://mathworks.com/products/gpu-coder.html)
34+
- [GPU Coder Interface for Deep Learning Libraries support package](https://www.mathworks.com/matlabcentral/fileexchange/68642-gpu-coder-interface-for-deep-learning-libraries) (Addon package for GPU Coder)
35+
- [GPU Coder Support Package for NVIDIA GPUs](https://mathworks.com/help/supportpkg/nvidia/index.html) (Addon package for GPU Coder)
36+
37+
# Getting Started
38+
39+
40+
Load a pose estimator model.
41+
42+
43+
44+
```matlab:Code
45+
detector = posenet.PoseEstimator;
46+
```
47+
48+
49+
50+
First, read a test image, then crop a person and resize it to fit to the network input.
51+
52+
53+
54+
```matlab:Code
55+
I = imread('visionteam1.jpg');
56+
bbox = [182 74 303 404];
57+
Iin = imresize(imcrop(I,bbox),detector.InputSize(1:2));
58+
```
59+
60+
61+
62+
Then, perform the pose estimation on the image. To visualise the results we can superimpose the detected keypoints on the original image.
63+
64+
65+
66+
```matlab:Code
67+
keypoints = detectPose(detector,Iin);
68+
J = detector.visualizeKeyPoints(Iin,keypoints);
69+
imshow(J);
70+
```
71+
72+
73+
![figure_0_png.jpg](doc/README_images/figure_0_png.jpg)
74+
75+
76+
77+
[Click here](doc/GettingStarted.md) for a complete example.
78+
79+
80+
# Examples
81+
82+
- [Estimate Human Pose For Multiple Person Using Pretrained Network](doc/SimplePoseNetForMultiPerson.md)
83+
- [Train Deep Neural Network for Human Pose Estimation](doc/SimplePoseNetTrainingExample.md)
84+
- [Human Pose Estimation With Webcam Images Using Deep Learning](doc/SimplePoseNetEstimationWithWebcamExample.md)
85+
- [Deploy Simple Pose Estimation on NVIDIA(R) Jetson(TM) Using GPU Coder(TM)](doc/SimplePoseNetEstimationOnJetson.md)
86+
87+
# About the Model
88+
89+
90+
The network architecture is based on Xiao's pose estimation network[1] which combines upsampling and convolutional parameters into transposed convolutional layers in a much simpler way, without using skip layer connections. We also use COCO dataset[2] which is one of the well known large public human pose dataset.
91+
92+
93+
94+
95+
[1] Xiao, Bin, Haiping Wu, and Yichen Wei. “Simple baselines for human pose estimation and tracking.” Proceedings of the European Conference on Computer Vision (ECCV). 2018.
96+
97+
98+
99+
100+
[2] Lin, T., et al. "Microsoft COCO: Common objects in context. arXiv 2014." *arXiv preprint arXiv:1405.0312*.
101+
102+
103+
104+
105+
*Copyright 2020 The MathWorks, Inc.*
106+
107+

README.mlx

107 KB
Binary file not shown.

SECURITY.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Reporting Security Vulnerabilities
2+
3+
If you believe you have discovered a security vulnerability, please report it to
4+
[security@mathworks.com](mailto:security@mathworks.com). Please see
5+
[MathWorks Vulnerability Disclosure Policy for Security Researchers](https://www.mathworks.com/company/aboutus/policies_statements/vulnerability-disclosure-policy.html)
6+
for additional information.

doc/GettingStarted.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Getting Started with Simple Pose Estimation
2+
## Load pretrained pose estimator model
3+
4+
```matlab:Code
5+
detector = posenet.PoseEstimator;
6+
```
7+
8+
## Read an image
9+
10+
11+
First, read a test image.
12+
13+
14+
15+
```matlab:Code
16+
I = imread('visionteam1.jpg');
17+
imshow(I);
18+
```
19+
20+
21+
![figure_0_png.jpg](GettingStarted_images/figure_0_png.jpg)
22+
23+
## Crop a person and resize it to fit to the network input.
24+
25+
```matlab:Code
26+
bbox = [182 74 303 404];
27+
Iin = imresize(imcrop(I,bbox),detector.InputSize(1:2));
28+
imshow(Iin);
29+
```
30+
31+
32+
![figure_1_png.jpg](GettingStarted_images/figure_1_png.jpg)
33+
34+
## Detect pose and visulaze on the original image
35+
36+
37+
To visualise the results we can superimpose the detected keypoints on the original image.
38+
39+
40+
41+
```matlab:Code
42+
keypoints = detectPose(detector,Iin);
43+
J = detector.visualizeKeyPoints(Iin,keypoints);
44+
imshow(J);
45+
```
46+
47+
48+
![figure_2_png.jpg](GettingStarted_images/figure_2_png.jpg)
49+
50+
51+
52+
*Copyright 2020 The MathWorks, Inc.*
53+
54+
87.8 KB
Loading
13.8 KB
Loading
15.1 KB
Loading

doc/README_images/figure_0_png.jpg

15.1 KB
Loading
+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Deploy Simple Pose Estimation on NVIDIA® Jetson™ Using GPU Coder™
2+
3+
4+
![image_0_png.jpg](SimplePoseNetEstimationOnJetson_images/image_0_png.jpg)
5+
6+
7+
8+
9+
Running on a Jetson Nano.
10+
11+
12+
13+
14+
![image_1_png.jpg](SimplePoseNetEstimationOnJetson_images/image_1_png.jpg)
15+
16+
17+
18+
19+
Running on a Jetson AGX Xavier.
20+
21+
22+
# **System Requirements**
23+
24+
25+
[https://www.mathworks.com/help/supportpkg/nvidia/ug/install-and-setup-prerequisites.html](https://www.mathworks.com/help/supportpkg/nvidia/ug/install-and-setup-prerequisites.html)
26+
27+
28+
# **Connect to the NVIDIA Hardware**
29+
30+
```matlab:Code
31+
clear;
32+
hwobj = jetson('192.168.55.1', 'nvidia', 'nvidia');
33+
```
34+
35+
# **Verify the GPU Environment**
36+
37+
38+
Use the [coder.checkGpuInstall](matlab:doc('coder.checkGpuInstall')) function and verify that the compilers and libraries needed for running this example are set up correctly.
39+
40+
41+
42+
```matlab:Code
43+
envCfg = coder.gpuEnvConfig('jetson');
44+
envCfg.DeepLibTarget = 'tensorrt';
45+
envCfg.DeepCodegen = 1;
46+
envCfg.HardwareObject = hwobj;
47+
coder.checkGpuInstall(envCfg);
48+
```
49+
50+
# **Prepare Pose Estimation for Stand-Alone Deployment**
51+
52+
53+
Include the webcam and display interfaces inside the Sobel edge detection application
54+
55+
56+
57+
```matlab:Code
58+
w = webcam(hwobj);
59+
img = snapshot(w);
60+
d = imageDisplay(hwobj);
61+
image(d,img);
62+
```
63+
64+
# Test Pose Estimation Function on MATLAB
65+
66+
```matlab:Code
67+
clear hwobj d w envCfg;
68+
figure;
69+
set(gcf,'Visible','on');
70+
simplePoseEstimation
71+
% Need to Ctrl+C to stop the running program.
72+
```
73+
74+
# **Generate CUDA Code for the Target Using GPU Coder**
75+
76+
```matlab:Code
77+
cfg = coder.gpuConfig('exe');
78+
cfg.Hardware = coder.hardware('NVIDIA Jetson');
79+
cfg.Hardware.BuildDir = '~/remoteBuildDir';
80+
cfg.DeepLearningConfig = coder.DeepLearningConfig('tensorrt');
81+
cfg.GenerateExampleMain = 'GenerateCodeAndCompile';
82+
codegen('-config ',cfg,'simplePoseEstimation.m','-report');
83+
```
84+
85+
# Run the Pose Estimation on the Target
86+
87+
88+
To run the generated executable on the target, use the MATLAB® runApplication function.
89+
90+
91+
92+
```matlab:Code
93+
clear hwobj;
94+
hwobj = jetson
95+
pid = runApplication(hwobj,'simplePoseEstimation');
96+
```
97+
98+
99+
```matlab:Code
100+
%killApplication(hwobj,'simplePoseEstimation');
101+
```
102+
103+
104+
105+
*Copyright 2020 The MathWorks, Inc.*
106+
107+
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Human Pose Estimation With Webcam Images Using Deep Learning
2+
3+
4+
This example shows how to predict human poses using a pretrained mode with a web camera.
5+
6+
7+
8+
9+
![image_0_png.jpg](SimplePoseNetEstimationWithWebcamExample_images/image_0_png.jpg)
10+
11+
12+
# Load Camera and Pretrained Network
13+
14+
15+
Connect to the camera and load a pretrained GoogLeNet network. You can use any pretrained network at this step. The example requires MATLAB Support Package for USB Webcams, and Deep Learning Toolbox™ Model *for GoogLeNet Network*. If you do not have the required support packages installed, then the software provides a download link.
16+
17+
18+
19+
```matlab:Code
20+
detector = posenet.PoseEstimator;
21+
cam = webcam;
22+
```
23+
24+
# **Continuously Estimate Human Pose**
25+
26+
```matlab:Code
27+
player = vision.DeployableVideoPlayer;
28+
I = zeros(256,192,3,'uint8');
29+
player(I);
30+
31+
while player.isOpen
32+
33+
% Read an image from web camera
34+
I = snapshot(cam);
35+
36+
% Crop the image fitting the network input size of 256x192
37+
Iinresize = imresize(I,[256 nan]);
38+
Itmp = Iinresize(:,(size(Iinresize,2)-192)/2:(size(Iinresize,2)-192)/2+192-1,:);
39+
Icrop = Itmp(1:256,1:192,1:3);
40+
41+
% Predict pose estimation
42+
heatmaps = detector.predict(Icrop);
43+
keypoints = detector.heatmaps2Keypoints(heatmaps);
44+
45+
% Visualize key points
46+
Iout = detector.visualizeKeyPoints(Icrop,keypoints);
47+
player(Iout);
48+
49+
if ~isOpen(player)
50+
break
51+
end
52+
end
53+
imshow(Iout);
54+
clear cam
55+
release(player)
56+
```
57+
58+
59+
60+
*Copyright 2020 MathWorks, Inc.*
61+
62+
Loading

0 commit comments

Comments
 (0)