Open15
RTMPose WholeBody 2d (133 Keypoints) との死闘 (mmpose) mmdeploy
# v1.2.0
git clone https://github.com/PINTO0309/mmdeploy.git \
&& cd mmdeploy \
&& git checkout v1.2.0 \
&& MMDEPLOY_VERSION=v1.2.0 \
&& TAG=mmdeploy-${MMDEPLOY_VERSION} \
&& docker build \
--no-cache \
-t pinto0309/${TAG} \
-f docker/Dockerfile.custom \
--build-arg MMDEPLOY_VERSION=${MMDEPLOY_VERSION} .
docker push pinto0309/mmdeploy-v1.2.0:latest
xhost +local: && \
docker run --rm -it \
--gpus all \
-v `pwd`:/workdir \
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix:rw \
--device /dev/video0:/dev/video0:mwr \
pinto0309/mmdeploy-v1.2.0:latest
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0
ls -l
total 40
drwxr-xr-x 1 user user 4096 Jul 16 13:52 mmdeploy
drwxr-xr-x 1 user user 4096 Jul 16 13:56 mmdetection
drwxr-xr-x 1 user user 4096 Jul 16 13:56 mmpose
drwxrwxr-x 1 user user 4096 Jun 16 16:25 onnxruntime-linux-x64-1.15.1
drwxr-xr-x 1 user user 4096 Jul 16 13:53 ppl.cv
cd mmdeploy
# run the command to convert RTMDet
# Model file can be either a local path or a download link
python tools/deploy.py \
configs/mmdet/detection/detection_onnxruntime_static.py \
../mmpose/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 \
demo/resources/human-pose.jpg \
--work-dir rtmpose-ort/rtmdet-nano \
--device cpu \
--show
# run the command to convert RTMPose
# Model file can be either a local path or a download link
python tools/deploy.py \
configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py \
../mmpose/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 \
demo/resources/human-pose.jpg \
--work-dir rtmpose-ort/rtmpose-m \
--device cpu \
--show
- conda無し・ランタイム全部ビルド済み mmdeploy PINTO スペシャルカスタムdocker imageコミットバージョン
Dockerfile.custom
# MIT License
# Copyright (c) 2023 Katsuya Hyodo
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
FROM docker.io/pinto0309/base-x64-ubuntu2204-cuda118:latest
ENV DEBIAN_FRONTEND=noninteractive
ARG CUDA=11.8
ARG ONNXRUNTIME_VERSION=1.15.1
ARG PPLCV_VERSION=v0.7.1
ENV FORCE_CUDA="1"
ENV TORCH_CUDA_ARCH_LIST=8.0;8.6
ARG MMDEPLOY_VERSION=v1.2.0
ARG MMPOSE_VERSION=v1.1.0
ARG MMDETECTION_VERSION=v3.1.0
ARG USERNAME=user
ARG WORKSPACE=/workspace
SHELL ["/bin/bash", "-c"]
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
wget \
libsm6 \
libxext6 \
libssl-dev \
libopencv-dev \
libspdlog-dev \
libxrender-dev \
libgl1-mesa-glx \
python-is-python3 \
python3-pip \
python3-all-dev \
python3-tk \
tk-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip install -U pip \
&& pip install pyyaml==6.0 \
&& pip install numpy==1.25.1 \
&& pip install ipython==8.14.0 \
&& pip install cython==0.29.36 \
&& pip install typing==3.7.4.3 \
&& pip install typing_extensions==4.7.1 \
&& pip install mkl==2023.2.0 \
&& pip install mkl-include==2023.2.0 \
&& pip install ninja==1.11.1 \
&& pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 \
--index-url https://download.pytorch.org/whl/cu118 \
&& pip install openmim==0.3.9 \
&& pip install mmcv==2.0.1 \
&& pip install mmengine==0.8.2 \
&& pip install onnxruntime-gpu==${ONNXRUNTIME_VERSION} \
&& pip install onnxsim==0.4.33
WORKDIR ${WORKSPACE}
RUN wget https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}.tgz \
&& tar -zxvf onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}.tgz \
&& rm onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}.tgz
ENV ONNXRUNTIME_DIR=${WORKSPACE}/onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}
RUN git clone -b ${MMDEPLOY_VERSION} https://github.com/open-mmlab/mmdeploy \
&& pushd mmdeploy \
&& git submodule update --init --recursive \
&& mkdir -p build \
&& pushd build \
&& cmake -DMMDEPLOY_TARGET_BACKENDS="ort" .. \
&& make -j$(nproc) \
&& popd \
&& mim install -e .
RUN git clone -b ${PPLCV_VERSION} https://github.com/openppl-public/ppl.cv.git \
&& cd ppl.cv \
&& ./build.sh cuda
ENV BACKUP_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
ENV LD_LIBRARY_PATH=/usr/local/cuda/compat/lib.real/:$LD_LIBRARY_PATH
RUN cd ${WORKSPACE}/mmdeploy \
&& rm -rf build/CM* build/cmake-install.cmake build/Makefile build/csrc \
&& mkdir -p build \
&& cd build \
&& cmake .. \
-DMMDEPLOY_BUILD_SDK=ON \
-DMMDEPLOY_BUILD_EXAMPLES=ON \
-DCMAKE_CXX_COMPILER=g++ \
-Dpplcv_DIR=${WORKSPACE}/ppl.cv/cuda-build/install/lib/cmake/ppl \
-DONNXRUNTIME_DIR=${ONNXRUNTIME_DIR} \
-DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \
-DMMDEPLOY_TARGET_DEVICES="cuda;cpu" \
-DMMDEPLOY_TARGET_BACKENDS="ort" \
-DMMDEPLOY_CODEBASES=all \
&& make -j$(nproc) \
&& make install \
&& export SPDLOG_LEVEL=warn
ENV LD_LIBRARY_PATH="${WORKSPACE}/mmdeploy/build/lib:${BACKUP_LD_LIBRARY_PATH}"
RUN git clone -b ${MMPOSE_VERSION} https://github.com/open-mmlab/mmpose.git \
&& pushd mmpose \
&& pip install -v -e . \
&& popd \
&& git clone -b ${MMDETECTION_VERSION} https://github.com/open-mmlab/mmdetection.git \
&& pushd mmdetection \
&& pip install -v -e . \
&& popd
RUN echo "root:root" | chpasswd \
&& useradd \
--create-home \
--home-dir /home/${USERNAME} \
--shell /bin/bash \
--user-group \
--groups adm,sudo \
${USERNAME} \
&& echo "${USERNAME}:${USERNAME}" | chpasswd \
&& cat /dev/null > /etc/sudoers.d/${USERNAME} \
&& echo "%${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> \
/etc/sudoers.d/${USERNAME} \
&& chown -R ${USERNAME}:${USERNAME} ${WORKSPACE}
USER ${USERNAME}
RUN echo "export USER=`whoami`" >> ~/.bashrc \
&& echo 'export PATH=/usr/local/cuda/bin:${PATH}' >> ~/.bashrc \
&& echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${WORKSPACE}/onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}/lib/:${LD_LIBRARY_PATH}" >> ~/.bashrc \
&& echo 'export PATH=${PATH}:${HOME}/.local/bin' >> ~/.bashrc
-
Whole Body
成功。これにて死闘終了。
python tools/deploy.py \
configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py \
../mmpose/projects/rtmpose/rtmpose/wholebody_2d_keypoint/rtmpose-l_8xb32-270e_coco-wholebody-384x288.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-l_simcc-coco-wholebody_pt-aic-coco_270e-384x288-eaeb96c8_20230125.pth \
demo/resources/human-pose.jpg \
--work-dir rtmpose-ort/rtmpose-wholebody-l \
--device cpu \
--show
python tools/deploy.py \
configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py \
../mmpose/projects/rtmpose/rtmpose/wholebody_2d_keypoint/rtmpose-m_8xb64-270e_coco-wholebody-256x192.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-coco-wholebody_pt-aic-coco_270e-256x192-cd5e845c_20230123.pth \
demo/resources/human-pose.jpg \
--work-dir rtmpose-ort/rtmpose-wholebody-m \
--device cpu \
--show
python tools/deploy.py \
configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py \
../mmpose/projects/rtmpose/rtmpose/wholebody_2d_keypoint/rtmpose-x_8xb32-270e_coco-wholebody-384x288.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-x_simcc-coco-wholebody_pt-body7_270e-384x288-401dfc90_20230629.pth \
demo/resources/human-pose.jpg \
--work-dir rtmpose-ort/rtmpose-wholebody-x \
--device cpu \
--show
- Hand
- Detection
python tools/deploy.py \ configs/mmdet/detection/detection_onnxruntime_static.py \ ../mmpose/projects/rtmpose/rtmdet/hand/rtmdet_nano_320-8xb32_hand.py \ https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmdet_nano_8xb32-300e_hand-267f9c8f.pth \ demo/resources/human-pose.jpg \ --work-dir rtmpose-ort/rtmdet-nano-hand \ --device cpu \ --show python tools/deploy.py \ configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py \ ../mmpose/projects/rtmpose/rtmpose/hand_2d_keypoint/rtmpose-m_8xb32-210e_coco-wholebody-hand-256x256.py \ https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-hand5_pt-aic-coco_210e-256x256-74fb594_20230320.pth \ demo/resources/hand.png \ --work-dir rtmpose-ort/rtmpose-hand \ --device cpu \ --show
- Detection
-
Animal
python tools/deploy.py \ configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py \ ../mmpose/projects/rtmpose/rtmpose/animal_2d_keypoint/rtmpose-m_8xb64-210e_ap10k-256x256.py \ https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-ap10k_pt-aic-coco_210e-256x256-7a041aa1_20230206.pth \ demo/resources/human-pose.jpg \ --work-dir rtmpose-ort/rtmpose-animal-m \ --device cpu \ --show
- Inference with WebCam
xhost +local: && \
docker run --rm -it \
--gpus all \
-v `pwd`:/workdir \
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix:rw \
--device /dev/video0:/dev/video0:mwr \
pinto0309/mmdeploy-v1.2.0:latest
cd mmpose
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/wholebody_2d_keypoint/rtmpose-x_8xb32-270e_coco-wholebody-384x288.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-x_simcc-coco-wholebody_pt-body7_270e-384x288-401dfc90_20230629.pth \
--input webcam \
--show
-
Simple Keypoints (skps)
のエクスポート - mmxxx にカスタムモジュールを認識させたうえで正常に動作させるには、
custom_codecs
とmodels
が配置されているフォルダまでのパスをPYTHONPATH
に登録する必要がある模様。
pwd
/workspace/mmdeploy
pushd ../mmpose/projects/skps
export PYTHONPATH=`pwd`:$PYTHONPATH
popd
echo $PYTHONPATH
/workspace/mmpose/projects/skps:
python tools/deploy.py \
configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py \
../mmpose/projects/skps/configs/td-hm_hrnetv2-w18_skps-1xb64-80e_wflw-256x256.py \
https://download.openmmlab.com/mmpose/v1/projects/skps/best_NME_epoch_80.pth \
demo/resources/human-pose.jpg \
--work-dir skps-ort \
--device cpu \
--show
python tools/deploy.py \
configs/mmdet/detection/detection_onnxruntime_static.py \
../mmpose/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 \
demo/resources/human-pose.jpg \
--work-dir rtmpose-ort/rtmdet-nano \
--device cpu \
--show
python tools/deploy.py \
configs/mmdet/detection/detection_onnxruntime_static.py \
../mmpose/projects/rtmpose/rtmdet/hand/rtmdet_nano_320-8xb32_hand.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmdet_nano_8xb32-300e_hand-267f9c8f.pth \
demo/resources/human-pose.jpg \
--work-dir rtmpose-ort/rtmdet-nano \
--device cpu \
--show