Installation Environment
environmental information
OpenI Qizhi Cluster
CPU: Intel® Xeon® Gold 6248 CPU @ 2.50GHz
Memory: 32G
GPU: NVIDIA Tesla T4 16G
CUDA: 11.0
Python: Python 3.7
Set domestic source
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Install Pytorch
pip3 install torch torchvision torchaudio
Install MMCV
Install MMCV with MIM
pip install -U openmim
mim install mmengine
mim install 'mmcv==2.0.0rc3'
mim install "mmdet>=3.0.0rc6"
Install additional toolkits
pip install opencv-python pillow matplotlib seaborn tqdm pycocotools
Install MMPose
Download MMPose
git clone https://github.com/open-mmlab/mmpose.git -b tutorial2023
Install MMPose
cd mmpose
mim install -e .
Download pre-trained model weight files and video clips
import os
# 创建 checkpoint 文件夹,用于存放预训练模型权重文件
os.mkdir('checkpoint')
# 创建 outputs 文件夹,用于存放预测结果
os.mkdir('outputs')
# 创建 data 文件夹,用于存放图片和视频素材
os.mkdir('data')
os.mkdir('data/test')
# 多人图片,来源:https://www.pexels.com/zh-cn/photo/2168292/
!wget https://zihao-openmmlab.obs.cn-east-3.myhuaweicloud.com/20220610-mmpose/images/multi-person.jpeg -O data/test/multi-person.jpeg
# 单人视频-唱跳篮球
!wget https://zihao-openmmlab.obs.myhuaweicloud.com/20220610-mmpose/videos/cxk.mp4 -P data/test
# 妈妈和女儿跳舞,经微信压缩
!wget https://zihao-openmmlab.obs.myhuaweicloud.com/20220610-mmpose/videos/mother_wx.mp4 -P data/test
# 两个女生跳舞视频,来源:https://mixkit.co/free-stock-video/two-girls-having-fun-in-a-retro-restaurant-42298/
!wget https://zihao-openmmlab.obs.cn-east-3.myhuaweicloud.com/20220610-mmpose/videos/two-girls.mp4 -O data/test/two-girls.mp4
Check that the installation was successful
# 检查 Pytorch
import torch, torchvision
print('Pytorch 版本', torch.__version__)
print('CUDA 是否可用',torch.cuda.is_available())
operation result
Pytorch 版本 2.0.1+cu117
CUDA 是否可用 True
# 检查 mmcv
import mmcv
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
print('MMCV版本', mmcv.__version__)
print('CUDA版本', get_compiling_cuda_version())
print('编译器版本', get_compiler_version())
operation result:
MMCV版本 2.0.0
CUDA版本 11.7
编译器版本 GCC 9.3
# 检查 mmpose
import mmpose
print('mmpose版本', mmpose.__version__)
operation result:
mmpose版本 1.0.0
Install MMDetection
Download MMDetection
git clone https://github.com/open-mmlab/mmdetection.git -b 3.x
Install MMDetection
cd mmdetection
pip install -v -e .
Download pre-trained model weight files and video clips
import os
# 创建 checkpoint 文件夹,用于存放预训练模型权重文件
os.mkdir('checkpoint')
# 创建 outputs 文件夹,用于存放预测结果
os.mkdir('outputs')
# 创建 data 文件夹,用于存放图片和视频素材
os.mkdir('data')
Check that the installation was successful
# 检查 Pytorch
import torch, torchvision
print('Pytorch 版本', torch.__version__)
print('CUDA 是否可用',torch.cuda.is_available())
operation result:
Pytorch 版本 2.0.1+cu117
CUDA 是否可用 True
# 检查 mmcv
import mmcv
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
print('MMCV版本', mmcv.__version__)
print('CUDA版本', get_compiling_cuda_version())
print('编译器版本', get_compiler_version())
operation result:
MMCV版本 2.0.0
CUDA版本 11.7
编译器版本 GCC 9.3
# 检查 mmdet
import mmdet
print('mmdetection版本', mmdet.__version__)
operation result:
mmdetection版本 3.0.0
MMPose pre-training model prediction - command line
Dataset directory
data/test/multi-person.jpeg
data/test/cxk.mp4
data/test/two_dancers.mp4
Model library pre-trained model
Object Detection Model
MMDetection model library:
https://github.com/open-mmlab/mmdetection/blob/master/docs/en/model_zoo.md
demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py
https://download.openmmlab.com/mmdetection/v2. 0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
MMPose Human Pose Estimation Model
configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_8xb64-210e_coco-256x192.py
https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w32_coco_256x192-c78dce93_20200708.pth
RTMPose Human Pose Estimation Model
RTMPose home page: https://github.com/open-mmlab/mmpose/tree/dev-1.x/projects/rtmpose
RTMPose-S
projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-s_8xb256-420e_coco-256x192.py
https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmpose-s_simcc-aic-coco_pt-aic-coco_420e-256x192-fcb2599b_20230126.pth
RTMPose-L
projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-l_8xb256-420e_coco-384x288.py
https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmpose-l_simcc-aic-coco_pt-aic-coco_420e-384x288-97d6cb0f_20230228.pth
Predicting a single image
python demo/topdown_demo_with_mmdet.py \
demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \
https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \
configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_8xb64-210e_coco-256x192.py \
https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w32_coco_256x192-c78dce93_20200708.pth \
--input data/test/multi-person.jpeg \
--output-root outputs/B1_HRNet_1 \
--device cuda:0 \
--bbox-thr 0.5 \
--kpt-thr 0.2 \
--nms-thr 0.3 \
--radius 8 \
--thickness 4 \
--draw-bbox \
--draw-heatmap \
--show-kpt-idx
# RTMPose
python demo/topdown_demo_with_mmdet.py \
demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \
https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \
projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-s_8xb256-420e_coco-256x192.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmpose-s_simcc-aic-coco_pt-aic-coco_420e-256x192-fcb2599b_20230126.pth \
--input data/test/multi-person.jpeg \
--output-root outputs/B1_RTM_1 \
--device cuda:0 \
--bbox-thr 0.5 \
--kpt-thr 0.5 \
--nms-thr 0.3 \
--radius 8 \
--thickness 4 \
--draw-bbox \
--draw-heatmap \
--show-kpt-idx
predictive video
python demo/topdown_demo_with_mmdet.py \
demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \
https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \
configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_8xb64-210e_coco-256x192.py \
https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w32_coco_256x192-c78dce93_20200708.pth \
--input data/test/mother_wx.mp4 \
--output-root outputs/B1_HRNet_2 \
--device cuda:0 \
--bbox-thr 0.5 \
--kpt-thr 0.2 \
--nms-thr 0.3 \
--radius 5 \
--thickness 2 \
--draw-bbox \
--draw-heatmap \
--show-kpt-idx
python demo/topdown_demo_with_mmdet.py \
demo/mmdetection_cfg/faster_rcnn_r50_fpn_coco.py \
https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \
projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-s_8xb256-420e_coco-256x192.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmpose-s_simcc-aic-coco_pt-aic-coco_420e-256x192-fcb2599b_20230126.pth \
--input data/test/mother_wx.mp4 \
--output-root outputs/B1_RTM_2 \
--device cuda:0 \
--bbox-thr 0.5 \
--kpt-thr 0.5 \
--nms-thr 0.3 \
--radius 5 \
--thickness 2 \
--draw-bbox \
--draw-heatmap \
--show-kpt-idx
MMPose pre-training model prediction-Python API
https://github.com/JeffDing/mmlabcamp/blob/main/Phase 2/MMPose pre-training model prediction-Python API.ipynb
Triangular target detection
https://github.com/JeffDing/mmlabcamp/blob/main/Phase 2/Triangle target detection.ipynb
MMPose, RTMPose triangular plate key point detection
install albumentations
pip install albumentations
https://github.com/JeffDing/mmlabcamp/blob/main/Phase 2/Triangle key point detection.ipynb
Triangular plate key point detection and prediction - command line
cd mmpose
python demo/topdown_demo_with_mmdet.py \
data/faster_r_cnn_triangle.py \
checkpoint/faster_r_cnn_triangle_epoch_50_202305120846-76d9dde3.pth \
data/rtmpose-s-triangle.py \
checkpoint/rtmpose-s-triangle-300-32642023_20230524.pth \
--input data/test_triangle/triangle_4.jpg \
--output-root outputs/G2_Fasterrcnn-RTMPose \
--device cuda:0 \
--bbox-thr 0.5 \
--kpt-thr 0.5 \
--nms-thr 0.3 \
--radius 36 \
--thickness 30 \
--draw-bbox \
--draw-heatmap \
--show-kpt-idx
python demo/topdown_demo_with_mmdet.py \
data/rtmdet_tiny_triangle.py \
checkpoint/rtmdet_tiny_triangle_epoch_200_202305120847-3cd02a8f.pth \
data/rtmpose-s-triangle.py \
checkpoint/rtmpose-s-triangle-300-32642023_20230524.pth \
--input data/test_triangle/triangle_4.jpg \
--output-root outputs/G2_RTMDet-RTMPose \
--device cuda:0 \
--bbox-thr 0.5 \
--kpt-thr 0.5 \
--nms-thr 0.3 \
--radius 36 \
--thickness 30 \
--draw-bbox \
--draw-heatmap \
--show-kpt-idx
Keypoint Detection Prediction
python demo/topdown_demo_with_mmdet.py \
data/rtmdet_tiny_triangle.py \
checkpoint/rtmdet_tiny_triangle_epoch_200_202305120847-3cd02a8f.pth \
data/rtmpose-s-triangle.py \
checkpoint/rtmpose-s-triangle-300-32642023_20230524.pth \
--input data/test_triangle/triangle_9.mp4 \
--output-root outputs/G2_Video \
--device cuda:0 \
--bbox-thr 0.5 \
--kpt-thr 0.5 \
--nms-thr 0.3 \
--radius 16 \
--thickness 10 \
--draw-bbox \
--draw-heatmap \
--show-kpt-idx