### Build MMPose from Source Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Clones the MMPose repository, navigates into the directory, installs requirements, and then installs MMPose in editable mode. This method is recommended for development. ```shell git clone https://github.com/open-mmlab/mmpose.git cd mmpose pip install -r requirements.txt pip install -v -e . ``` -------------------------------- ### Launch TensorBoard for Visualization Source: https://github.com/spiideo/mmpose/blob/main/docs/en/user_guides/train_and_test.md Starts the TensorBoard server to visualize training progress. It requires the path to the log directory where TensorBoard event files are saved. ```shell tensorboard --logdir ${WORK_DIR}/${TIMESTAMP}/vis_data ``` -------------------------------- ### Install TensorBoard for Visualization Source: https://github.com/spiideo/mmpose/blob/main/docs/en/user_guides/train_and_test.md Installs the TensorBoard library, a tool for visualizing machine learning experiments. This is a prerequisite for enabling TensorBoard visualization in MMPose. ```shell pip install tensorboard ``` -------------------------------- ### Install rtmlib from PyPI Source: https://github.com/spiideo/mmpose/blob/main/projects/rtmpose/examples/rtmlib/README.md Installs the rtmlib library from the Python Package Index (PyPI) using pip. This is the simplest way to get started. ```shell pip install rtmlib -i https://pypi.org/simple ``` -------------------------------- ### Install MMEngine using Pip Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md This command installs the MMEngine library using pip, providing an alternative to using MIM for installation. Ensure pip is up-to-date before running this command. ```shell pip install mmengine ``` -------------------------------- ### Install MMEngine, MMCV, and MMDetection with MIM (Python) Source: https://github.com/spiideo/mmpose/blob/main/demo/MMPose_Tutorial.ipynb This code snippet demonstrates how to install MMEngine, MMCV, and MMDetection using the MIM package manager. It first installs or upgrades `openmim`, then proceeds to install the specified packages with version constraints. Ensure you have Python and pip installed. ```python %pip install -U openmim !mim install mmengine !mim install "mmcv>=2.0.0" !mim install "mmdet>=3.0.0" ``` -------------------------------- ### Install xtcocotools from source Source: https://github.com/spiideo/mmpose/blob/main/docs/en/faq.md Provides instructions to clone the `xtcocoapi` repository and install `xtcocotools` from its source code. This method is useful when PyPI installation encounters issues or for developers needing the latest changes. ```bash git clone https://github.com/jin-s13/xtcocoapi cd xtcocoapi python setup.py install ``` -------------------------------- ### Install PyTorch with CUDA Support Source: https://github.com/spiideo/mmpose/blob/main/demo/MMPose_Tutorial.ipynb This code installs PyTorch, torchvision, and torchaudio, specifying a CUDA version. It's essential for users with CUDA-enabled GPUs to leverage hardware acceleration for pose estimation tasks. Ensure the CUDA version specified matches your system's setup. ```python # install dependencies: (if your colab has CUDA 11.8) %pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 ``` -------------------------------- ### MMPose Full Configuration Example with Codec Source: https://github.com/spiideo/mmpose/blob/main/docs/en/advanced_guides/codecs.md This is a comprehensive example of an MMPose configuration file, illustrating the setup of a 'TopdownPoseEstimator'. It includes definitions for the codec, model architecture (backbone, neck, head), data preprocessor, and training/testing pipelines. The codec is utilized in both the target generation and the model head, demonstrating its central role in the pose estimation workflow. ```Python # codec settings codec = dict(type='RegressionLabel', input_size=(192, 256)) ## definition ## # model settings model = dict( type='TopdownPoseEstimator', data_preprocessor=dict( type='PoseDataPreprocessor', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], bgr_to_rgb=True), backbone=dict( type='ResNet', depth=50, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50'), ), neck=dict(type='GlobalAveragePooling'), head=dict( type='RLEHead', in_channels=2048, num_joints=17, loss=dict(type='RLELoss', use_target_weight=True), decoder=codec), ## Head ## test_cfg=dict( flip_test=True, shift_coords=True, )) # base dataset settings dataset_type = 'CocoDataset' data_mode = 'topdown' data_root = 'data/coco/' backend_args = dict(backend='local') # pipelines train_pipeline = [ dict(type='LoadImage', backend_args=backend_args), dict(type='GetBBoxCenterScale'), dict(type='RandomFlip', direction='horizontal'), dict(type='RandomHalfBody'), dict(type='RandomBBoxTransform'), dict(type='TopdownAffine', input_size=codec['input_size']), dict(type='GenerateTarget', encoder=codec), ## Generate Target ## dict(type='PackPoseInputs') ] test_pipeline = [ dict(type='LoadImage', backend_args=backend_args), dict(type='GetBBoxCenterScale'), dict(type='TopdownAffine', input_size=codec['input_size']), dict(type='PackPoseInputs') ] ``` -------------------------------- ### Run MMPose Inference Demo from Source (Shell) Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md This shell command executes an image inference demo using MMPose installed from source. It takes an image file, configuration file, and checkpoint file as input, and outputs a visualization with predicted keypoints and heatmaps. Ensure you are in the '$MMPOSE' directory. ```shell python demo/image_demo.py \ tests/data/coco/000000000785.jpg \ td-hm_hrnet-w48_8xb32-210e_coco-256x192.py \ td-hm_hrnet-w48_8xb32-210e_coco-256x192-0e67c616_20220913.pth \ --out-file vis_results.jpg \ --draw-heatmap ``` -------------------------------- ### Install SMPLX Tools Source: https://github.com/spiideo/mmpose/blob/main/docs/en/dataset_zoo/3d_body_keypoint.md Installs the necessary SMPLX library, which is a dependency for generating 3D keypoints from the UBody dataset. This ensures that the 3D human models can be processed correctly. ```shell pip install smplx ``` -------------------------------- ### Install Cython before xtcocotools Source: https://github.com/spiideo/mmpose/blob/main/docs/en/faq.md This snippet shows the necessary step of installing `cython` before attempting to install `xtcocotools` from source. This is a prerequisite for compiling `xtcocotools` when direct pip installation fails due to missing cython modules. ```bash pip install cython git clone https://github.com/jin-s13/xtcocoapi cd xtcocoapi python setup.py install ``` -------------------------------- ### Install rtmlib from Source Source: https://github.com/spiideo/mmpose/blob/main/projects/rtmpose/examples/rtmlib/README.md Installs rtmlib from its source code. This involves cloning the repository, installing requirements, and then performing a local installation. It also includes optional installations for GPU acceleration with onnxruntime or openvino. ```shell git clone https://github.com/Tau-J/rtmlib.git cd rtmlib pip install -r requirements.txt pip install -e . # [optional] # pip install onnxruntime-gpu # pip install openvino ``` -------------------------------- ### MMPose Training Configuration Examples (Python) Source: https://github.com/spiideo/mmpose/blob/main/configs/body_2d_keypoint/topdown_heatmap/coco/hrnet_coco_aic.md Python configuration files for training MMPose models. These examples demonstrate how to merge or combine COCO and AI Challenger datasets for training. ```python # Example for coco-aic-merge # This configuration leverages AIC data with partial keypoints as auxiliary data to train a COCO model # File path: /configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_8xb64-210e_coco-aic-256x192-merge.py ``` ```python # Example for coco-aic-combine # This configuration constructs a combined dataset whose keypoints are the union of COCO and AIC keypoints to train a model that predicts keypoints of both datasets. # File path: /configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_hrnet-w32_8xb64-210e_coco-aic-256x192-combine.py ``` -------------------------------- ### Run MMPose Docker Container Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Runs a Docker container with GPU support and shared memory, mounting a local data directory. This command starts an MMPose environment within a Docker container. ```shell docker run --gpus all --shm-size=8g -it -v {DATA_DIR}:/mmpose/data mmpose ``` -------------------------------- ### Verify MMPose Installation Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Checks if MMPose has been installed correctly by printing its version number. This is a simple verification step after installation. ```python import mmpose print(mmpose.__version__) ``` -------------------------------- ### Install MMPose from Source on Google Colab Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Clones the MMPose repository and installs it in editable mode. This command assumes the previous dependency installation steps have been completed. ```shell !git clone https://github.com/open-mmlab/mmpose.git %cd mmpose !pip install -e . ``` -------------------------------- ### Run Pose Tracking Inference on Video with MMDeploy CLI Source: https://github.com/spiideo/mmpose/blob/main/projects/rtmpose/README.md This command-line interface (CLI) example demonstrates how to perform pose tracking inference on a video file using the `pose_tracker` executable. It requires paths to the object detection and pose estimation models, the input video file, and allows configuration of the device and output settings. Webcam input is supported by passing '0' to the input argument. ```shell # go to the mmdeploy folder cd ${PATH_TO_MMDEPLOY}/build/bin/ # inference for a video ./pose_tracker rtmpose-ort/rtmdet-nano/ rtmpose-ort/rtmpose-m/ your_video.mp4 --device cpu required arguments: det_model Object detection model path [string] pose_model Pose estimation model path [string] input Input video path or camera index [string] optional arguments: --device Device name, e.g. "cpu", "cuda" [string = "cpu"] --output Output video path or format string [string = ""] --output_size Long-edge of output frames [int32 = 0] --flip Set to 1 for flipping the input horizontally [int32 = 0] --show Delay passed to `cv::waitKey` when using `cv::imshow`; -1: disable [int32 = 1] --skeleton Path to skeleton data or name of predefined skeletons: "coco", "coco-wholebody" [string = "coco"] --background Output background, "default": original image, "black": black background [string = "default"] --det_interval Detection interval [int32 = 1] --det_label Detection label use for pose estimation [int32 = 0] (0 refers to 'person' in coco) --det_thr Detection score threshold [double = 0.5] --det_min_bbox_size Detection minimum bbox size [double = -1] --det_nms_thr NMS IOU threshold for merging detected bboxes and bboxes from tracked targets [double = 0.7] --pose_max_num_bboxes Max number of bboxes used for pose estimation per frame [int32 = -1] --pose_kpt_thr Threshold for visible key-points [double = 0.5] --pose_min_keypoints Min number of key-points for valid poses, -1 indicates ceil(n_kpts/2) [int32 = -1] --pose_bbox_scale Scale for expanding key-points to bbox [double = 1.25] --pose_min_bbox_size Min pose bbox size, tracks with bbox size smaller than the threshold will be dropped [double = -1] --pose_nms_thr NMS OKS/IOU threshold for suppressing overlapped poses, useful when multiple pose estimations collapse to the same target [double = 0.5] --track_iou_thr IOU threshold for associating missing tracks [double = 0.4] --track_max_missing Max number of missing frames before a missing tracks is removed [int32 = 10] ``` -------------------------------- ### MMPose Data Pipeline Configuration Example Source: https://github.com/spiideo/mmpose/blob/main/docs/en/advanced_guides/customize_transforms.md Illustrates how to configure a data pipeline in MMPose's configuration files, including RandomFlip, RandomHalfBody, RandomBBoxTransform, and TopdownAffine for data augmentation and transformation. ```python train_pipeline_stage2 = [ ... dict(type='RandomFlip', direction='horizontal'), dict(type='RandomHalfBody'), dict( type='RandomBBoxTransform', shift_factor=0., scale_factor=[0.75, 1.25], rotate_factor=60), dict( type='TopdownAffine', input_size=codec['input_size']), ... ] ``` -------------------------------- ### Install MMPose Dependencies using MIM Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Installs core MMPose dependencies, MMEngine and MMCV, using the MIM package manager. It also shows how to install MMDetection if needed for demo scripts. ```shell pip install -U openmim mim install mmengine mim install "mmcv>=2.0.1" mim install "mmdet>=3.1.0" ``` -------------------------------- ### Download Example Videos Source: https://github.com/spiideo/mmpose/blob/main/projects/just_dance/just_dance_demo.ipynb Downloads sample videos for student and teacher actions using `wget`. It ensures the 'resources' directory exists before downloading. These videos are used for pose estimation tasks. ```python # download example videos from mmengine.utils import mkdir_or_exist mkdir_or_exist('resources') ! wget -O resources/student_video.mp4 https://download.openmmlab.com/mmpose/v1/projects/just_dance/tom.mp4 ! wget -O resources/teacher_video.mp4 https://download.openmmlab.com/mmpose/v1/projects/just_dance/idol_producer.mp4 # ! wget -O resources/student_video.mp4 https://download.openmmlab.com/mmpose/v1/projects/just_dance/tsinghua_30fps.mp4 student_video = 'resources/student_video.mp4' teacher_video = 'resources/teacher_video.mp4' ``` -------------------------------- ### Install MMPose Dependencies on Google Colab Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Installs MMEngine, MMCV, and MMPose on Google Colab using MIM. This is a prerequisite for using MMPose in a Colab environment. ```shell !pip3 install openmim !mim install mmengine !mim install "mmcv>=2.0.1" ``` -------------------------------- ### Install MMPose as a Python Package Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Installs MMPose as a Python package using pip with the MIM package manager. This is the standard method for using MMPose as a dependency in other projects. ```shell mim install "mmpose>=1.1.0" ``` -------------------------------- ### Testing and Evaluating Models Source: https://context7.com/spiideo/mmpose/llms.txt These command-line examples demonstrate how to test and evaluate trained models on test datasets. They cover single GPU testing, multi-GPU testing using a distributed script, saving predictions to a file, visualizing predictions, and overriding testing configurations. ```shell # Single GPU testing python tools/test.py \ configs/body_2d_keypoint/rtmpose/coco/rtmpose-s_8xb256-420e_coco-256x192.py \ work_dirs/rtmpose_s/best_coco_AP_epoch_420.pth # Multi-GPU testing (4 GPUs) bash tools/dist_test.sh \ configs/body_2d_keypoint/rtmpose/coco/rtmpose-s_8xb256-420e_coco-256x192.py \ work_dirs/rtmpose_s/best_coco_AP_epoch_420.pth \ 4 # Save predictions to file python tools/test.py \ configs/body_2d_keypoint/rtmpose/coco/rtmpose-s_8xb256-420e_coco-256x192.py \ work_dirs/rtmpose_s/best_coco_AP_epoch_420.pth \ --out results.pkl # Visualize predictions during testing python tools/test.py \ configs/body_2d_keypoint/rtmpose/coco/rtmpose-s_8xb256-420e_coco-256x192.py \ work_dirs/rtmpose_s/best_coco_AP_epoch_420.pth \ --show-dir vis_test # Override config for testing python tools/test.py \ configs/body_2d_keypoint/rtmpose/coco/rtmpose-s_8xb256-420e_coco-256x192.py \ work_dirs/rtmpose_s/best_coco_AP_epoch_420.pth \ --cfg-options test_dataloader.batch_size=32 ``` -------------------------------- ### Train an MMPose Model Source: https://github.com/spiideo/mmpose/blob/main/docs/en/quick_run.md This bash command initiates the training process for an MMPose model using a specified configuration file. It assumes a single GPU setup by default but can be extended for distributed training. The command leverages the 'train.py' script provided by MMPose. ```Bash python tools/train.py configs/body_2d_keypoint/topdown_regression/coco/td-reg_res50_rle-8xb64-210e_coco-256x192.py ``` -------------------------------- ### Install PyTorch on CPU-only Platforms Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Installs PyTorch and torchvision for CPU-only environments using conda. This is suitable for systems without dedicated GPUs or when GPU support is not required. ```shell conda install pytorch torchvision cpuonly -c pytorch ``` -------------------------------- ### Train MMPose Model with Single GPU Source: https://github.com/spiideo/mmpose/blob/main/projects/example_project/README.md Command to initiate model training using a single GPU with MMPose. It requires specifying the configuration file for the model. ```shell mim train mmpose configs/example-head-loss_hrnet-w32_8xb64-210e_coco-256x192.py ``` -------------------------------- ### Install PyTorch on GPU Platforms Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Installs PyTorch and torchvision for GPU-enabled systems using conda. This command automatically selects the latest compatible versions of PyTorch and cudatoolkit. Users should verify compatibility with their environment. ```shell conda install pytorch torchvision -c pytorch ``` -------------------------------- ### Install Dependencies for Pose Anything Source: https://github.com/spiideo/mmpose/blob/main/projects/pose_anything/README.md Installs the 'timm' library, a common dependency for machine learning projects, after MMPose has been set up. Ensure a virtual environment is used for better dependency management. ```bash pip install timm ``` -------------------------------- ### Initialize MMPose Runner from Config Source: https://github.com/spiideo/mmpose/blob/main/demo/MMPose_Tutorial.ipynb Python code demonstrating how to import necessary classes from mmengine and initialize an MMPose runner using a configuration object (cfg). It also shows how to set data preprocessor configurations. ```python from mmengine.config import Config, DictAction from mmengine.runner import Runner # set preprocess configs to model cfg.model.setdefault('data_preprocessor', cfg.get('preprocess_cfg', {})) # build the runner from config runner = Runner.from_cfg(cfg) ``` -------------------------------- ### Install MMCV with Pip for Specific PyTorch and CUDA Versions Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md This command installs the MMCV library using pip, specifically for a given PyTorch and CUDA version. It uses a find-url to locate the correct pre-built wheels. This method is an alternative to using MIM and requires careful selection of the find-url based on your environment. ```shell pip install 'mmcv>=2.0.1' -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10/index.html ``` -------------------------------- ### Install MMPose and MMDetection for OpenPose Skeleton Generation Source: https://github.com/spiideo/mmpose/blob/main/projects/mmpose4aigc/README.md Installs the necessary MMPose and MMDetection libraries along with their dependencies. It also downloads pre-trained models required for skeleton generation. This setup is crucial for the OpenPose-style skeleton generation process. ```shell # install mmpose mmdet pip install openmim git clone https://github.com/open-mmlab/mmpose.git cd mmpose mim install -e . mim install "mmdet>=3.0.0rc6" # download models bash download_models.sh ``` -------------------------------- ### Custom Dataset Info Configuration Example (Python) Source: https://github.com/spiideo/mmpose/blob/main/docs/en/advanced_guides/customize_datasets.md Provides a simplified example of a `dataset_info` configuration file in Python, which is essential for defining metadata about a custom dataset. It outlines the structure for `keypoint_info`, `skeleton_info`, `joint_weights`, and `sigmas`, crucial for visualization, data augmentation, and evaluation. ```python dataset_info = dict( dataset_name='coco', paper_info=dict( author='Lin, Tsung-Yi and Maire, Michael and ' 'Belongie, Serge and Hays, James and ' 'Perona, Pietro and Ramanan, Deva and ' r'Doll{\'a}r, Piotr and Zitnick, C Lawrence', title='Microsoft coco: Common objects in context', container='European conference on computer vision', year='2014', homepage='http://cocodataset.org/', ), keypoint_info={ 0: dict(name='nose', id=0, color=[51, 153, 255], type='upper', swap=''), 1: dict( name='left_eye', id=1, color=[51, 153, 255], type='upper', swap='right_eye'), ... 16: dict( name='right_ankle', id=16, color=[255, 128, 0], type='lower', swap='left_ankle') }, skeleton_info={ 0: dict(link=('left_ankle', 'left_knee'), id=0, color=[0, 255, 0]), ... 18: dict( link=('right_ear', 'right_shoulder'), id=18, color=[51, 153, 255]) }, joint_weights=[ 1., 1., 1., 1., 1., 1., 1., 1.2, 1.2, 1.5, 1.5, 1., 1., 1.2, 1.2, 1.5, 1.5 ], sigmas=[ 0.026, 0.025, 0.025, 0.035, 0.035, 0.079, 0.079, 0.072, 0.072, 0.062, 0.062, 0.107, 0.107, 0.087, 0.087, 0.089, 0.089 ]) ``` -------------------------------- ### C++ Pose Detection with MMDeploy SDK Source: https://github.com/spiideo/mmpose/blob/main/projects/rtmpose/README.md This C++ example demonstrates pose detection using the MMDeploy SDK. It integrates with OpenCV for image handling and includes utility functions for argument parsing. The code initializes a PoseDetector, applies it to an image (optionally with a bounding box), and draws the detected keypoints. To build this example, ensure MMDeploy is configured in your CMake project. ```cpp #include "mmdeploy/pose_detector.hpp" #include "opencv2/imgcodecs.hpp" #include "opencv2/imgproc.hpp" #include "utils/argparse.h" // See: https://github.com/open-mmlab/mmdeploy/blob/main/demo/csrc/cpp/utils/argparse.h DEFINE_ARG_string(model_path, "Model path"); DEFINE_ARG_string(image_path, "Input image path"); DEFINE_STRING(device_name, "cpu", R"(Device name, e.g. "cpu", "cuda")"); DEFINE_int32(bbox_x, -1, R"(x position of the bounding box)"); DEFINE_int32(bbox_y, -1, R"(y position of the bounding box)"); DEFINE_int32(bbox_w, -1, R"(width of the bounding box)"); DEFINE_int32(bbox_h, -1, R"(height of the bounding box)"); int main(int argc, char* argv[]) { if (!utils::ParseArguments(argc, argv)) { return -1; } cv::Mat img = cv::imread(ARGS_image_path); mmdeploy::PoseDetector detector(mmdeploy::Model{ARGS_model_path}, mmdeploy::Device{FLAGS_device_name, 0}); mmdeploy::PoseDetector::Result result{0, 0, nullptr}; if (FLAGS_bbox_x == -1 || FLAGS_bbox_y == -1 || FLAGS_bbox_w == -1 || FLAGS_bbox_h == -1) { result = detector.Apply(img); } else { // convert (x, y, w, h) -> (left, top, right, bottom) mmdeploy::cxx::Rect rect; rect.left = FLAGS_bbox_x; rect.top = FLAGS_bbox_y; rect.right = FLAGS_bbox_x + FLAGS_bbox_w; rect.bottom = FLAGS_bbox_y + FLAGS_bbox_h; result = detector.Apply(img, {rect}); } // Draw circles at detected keypoints for (size_t i = 0; i < result[0].length; ++i) { cv::Point keypoint(result[0].point[i].x, result[0].point[i].y); cv::circle(img, keypoint, 1, cv::Scalar(0, 255, 0), 2); // Draw filled circle } // Save the output image cv::imwrite("output_pose.png", img); return 0; } ``` ```cmake find_package(MMDeploy REQUIRED) target_link_libraries(${name} PRIVATE mmdeploy ${OpenCV_LIBS}) ``` -------------------------------- ### Run Pose Anything Demo with Custom Images Source: https://github.com/spiideo/mmpose/blob/main/projects/pose_anything/README.md Executes the demo script for Pose Anything using specified support and query images, a configuration file, and a pretrained checkpoint. This script allows for on-the-fly testing with custom inputs. ```bash python demo.py --support [path_to_support_image] --query [path_to_query_image] --config configs/demo_b.py --checkpoint [path_to_pretrained_ckpt] ``` -------------------------------- ### Run MMPose Inference Demo with Pip (Python) Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md This Python code snippet demonstrates how to perform top-down inference using MMPose installed via pip. It initializes the model with specified configuration and checkpoint files and then runs inference on an input image. The results contain predicted keypoint locations and scores. ```python from mmpose.apis import inference_topdown, init_model from mmpose.utils import register_all_modules register_all_modules() config_file = 'td-hm_hrnet-w48_8xb32-210e_coco-256x192.py' checkpoint_file = 'td-hm_hrnet-w48_8xb32-210e_coco-256x192-0e67c616_20220913.pth' model = init_model(config_file, checkpoint_file, device='cpu') # or device='cuda:0' # please prepare an image with person results = inference_topdown(model, 'demo.jpg') ``` -------------------------------- ### Run Webcam Pose Estimation with MMPose Demo Script Source: https://github.com/spiideo/mmpose/blob/main/demo/docs/en/webcam_api_demo.md This example demonstrates how to use a MMPose demo script, specifically `topdown_demo_with_mmdet.py`, for webcam-based pose estimation. It requires specifying 'webcam' as the input and includes model configuration and checkpoint paths. The `--show` argument displays the results. ```shell python demo/topdown_demo_with_mmdet.py \ projects/rtmpose/rtmdet/person/rtmdet_nano_320-8xb32_coco-person.py \ https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth \ projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-m_8xb256-420e_coco-256x192.py \ https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-aic-coco_pt-aic-coco_420e-256x192-63eb25f7_20230126.pth \ --input webcam \ --show ``` -------------------------------- ### Build MMPose Docker Image Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Builds a Docker image for MMPose, including PyTorch, CUDA, and CUDNN. This command uses the provided Dockerfile to create a reproducible environment. ```shell docker build -t mmpose mmpose docker/ ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md Creates a new conda environment named 'openmmlab' with Python 3.8 and activates it. This ensures a clean and isolated environment for the project dependencies. ```shell conda create --name openmmlab python=3.8 -y conda activate openmmlab ``` -------------------------------- ### Perform Inference with a Pretrained MMPose Model Source: https://github.com/spiideo/mmpose/blob/main/docs/en/quick_run.md This bash script demonstrates how to perform pose estimation on an image using a pretrained MMPose model. It requires the image path, the model configuration file, and the path to the pretrained model weights. The output is a visualized result of the pose estimation. ```Bash python demo/image_demo.py \ tests/data/coco/000000000785.jpg \ configs/body_2d_keypoint/topdown_regression/coco/td-reg_res50_rle-8xb64-210e_coco-256x192.py \ https://download.openmmlab.com/mmpose/top_down/deeppose/deeppose_res50_coco_256x192_rle-2ea9bb4a_20220616.pth ``` -------------------------------- ### MMPose Configuration Inheritance Example Source: https://github.com/spiideo/mmpose/blob/main/docs/en/user_guides/configs.md Demonstrates how to inherit the default runtime configuration in MMPose projects. The `_base_` variable is used to specify the path to the base configuration file, providing a starting point for your project's settings. ```Python _base_ = ['../../../_base_/default_runtime.py'] # take the config file as the starting point of the relative path ``` -------------------------------- ### Download MMPose Config and Checkpoint Files Source: https://github.com/spiideo/mmpose/blob/main/docs/en/installation.md This command downloads the necessary configuration and checkpoint files for MMPose to run inference demos. The download time depends on network speed, and it results in .py and .pth files in the current directory. ```shell mim download mmpose --config td-hm_hrnet-w48_8xb32-210e_coco-256x192 --dest . ``` -------------------------------- ### Train DWPose with First Stage Distillation Source: https://github.com/spiideo/mmpose/blob/main/configs/wholebody_2d_keypoint/dwpose/README.md This command initiates the training process for DWPose using the first stage of distillation. It requires a configuration file and the number of processes to use for distributed training. The output is a trained model checkpoint. ```bash bash tools/dist_train.sh configs/wholebody_2d_keypoint/dwpose/ubody/s1_dis/rtmpose_x_dis_l_coco-ubody-384x288.py 8 ``` -------------------------------- ### Check System Environment Versions Source: https://github.com/spiideo/mmpose/blob/main/demo/MMPose_Tutorial.ipynb This snippet checks the versions of essential development tools like NVCC, GCC, and Python within the current Conda environment. These checks are crucial for ensuring compatibility and proper setup before installing MMPose and its dependencies. ```shell # check NVCC version !nvcc -V # check GCC version !gcc --version # check python in conda environment !which python ``` -------------------------------- ### MMDeploy SDK Inference Example (Python) Source: https://github.com/spiideo/mmpose/blob/main/projects/rtmpose/README.md Provides a basic Python code structure for performing inference using the MMDeploy SDK. This snippet assumes that the model has been converted and the necessary SDK files (pipeline.json, deploy.json, detail.json) have been dumped. ```python # SDK Python API example # ... code to follow ... ``` -------------------------------- ### Resolve 'No module named 'mmcv.ops'' Error Source: https://github.com/spiideo/mmpose/blob/main/docs/zh_cn/faq.md Outlines the steps to fix 'No module named 'mmcv.ops'' or 'No module named 'mmcv._ext'' errors. It requires uninstalling the current 'mmcv' and then reinstalling 'mmcv-full' according to the official installation guide. ```bash pip uninstall mmcv # Follow the official installation instruction to install mmcv-full ``` -------------------------------- ### Run 2D Hand Demo on CPU (Shell) Source: https://github.com/spiideo/mmpose/blob/main/demo/docs/en/2d_hand_demo.md This command demonstrates running the 2D hand keypoint detection demo using the CPU. It specifies the MMDetection and MMPose configuration files and checkpoint URLs, an input image, and explicitly sets the device to 'cpu'. ```shell python demo/topdown_demo_with_mmdet.py \ demo/mmdetection_cfg/rtmdet_nano_320-8xb32_hand.py \ https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmdet_nano_8xb32-300e_hand-267f9c8f.pth \ configs/hand_2d_keypoint/rtmpose/hand5/rtmpose-m_8xb256-210e_hand5-256x256.py \ https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-hand5_pt-aic-coco_210e-256x256-74fb594_20230320.pth \ --input tests/data/onehand10k/9.jpg \ --show --draw-heatmap --device cpu ```