diff --git a/extras/mmdeploy/README.md b/extras/mmdeploy/README.md new file mode 100644 index 0000000..e8c4eb5 --- /dev/null +++ b/extras/mmdeploy/README.md @@ -0,0 +1,41 @@ +# Exporting MMPose models + +```bash +docker build --progress=plain -f extras/mmdeploy/dockerfile -t rpt_mmdeploy . + +./extras/mmdeploy/run_container.sh +``` + +
+ +## ONNX + +```bash +cd /mmdeploy/ +cp /RapidPoseTriangulation/extras/mmdeploy/configs/detection_onnxruntime_static-320x320.py configs/mmdet/detection/ + +python3 ./tools/deploy.py \ + configs/mmdet/detection/detection_onnxruntime_static-320x320.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 \ + /mmpose/projects/rtmpose/examples/onnxruntime/human-pose.jpeg \ + --work-dir work_dir \ + --show + +mv /mmdeploy/work_dir/end2end.onnx /RapidPoseTriangulation/extras/mmdeploy/exports/rtmdet_nano_320.onnx +``` + +```bash +cd /mmdeploy/ +cp /RapidPoseTriangulation/extras/mmdeploy/pose-detection_simcc_onnxruntime_static-384x288.py configs/mmpose/ + +python3 ./tools/deploy.py \ + configs/mmpose/pose-detection_simcc_onnxruntime_static-384x288.py \ + /mmpose/projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-m_8xb256-420e_coco-384x288.py \ + https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-body7_pt-body7_420e-384x288-65e718c4_20230504.pth \ + /mmpose/projects/rtmpose/examples/onnxruntime/human-pose.jpeg \ + --work-dir work_dir \ + --show + +mv /mmdeploy/work_dir/end2end.onnx /RapidPoseTriangulation/extras/mmdeploy/exports/rtmpose-m_384.onnx +``` diff --git a/extras/mmdeploy/configs/detection_onnxruntime_static-320x320.py b/extras/mmdeploy/configs/detection_onnxruntime_static-320x320.py new file mode 100644 index 0000000..a619c01 --- /dev/null +++ b/extras/mmdeploy/configs/detection_onnxruntime_static-320x320.py @@ -0,0 +1,5 @@ +_base_ = ["../_base_/base_static.py", "../../_base_/backends/onnxruntime.py"] + +onnx_config = dict( + input_shape=[320, 320], +) diff --git a/extras/mmdeploy/configs/pose-detection_simcc_onnxruntime_static-384x288.py b/extras/mmdeploy/configs/pose-detection_simcc_onnxruntime_static-384x288.py new file mode 100644 index 0000000..9d41100 --- /dev/null +++ b/extras/mmdeploy/configs/pose-detection_simcc_onnxruntime_static-384x288.py @@ -0,0 +1,8 @@ +_base_ = ["./pose-detection_static.py", "../_base_/backends/onnxruntime.py"] + +onnx_config = dict( + input_shape=[288, 384], + output_names=["simcc_x", "simcc_y"], +) + +codebase_config = dict(export_postprocess=False) # do not export get_simcc_maximum diff --git a/extras/mmdeploy/dockerfile b/extras/mmdeploy/dockerfile new file mode 100644 index 0000000..9333901 --- /dev/null +++ b/extras/mmdeploy/dockerfile @@ -0,0 +1,32 @@ +FROM openmmlab/mmdeploy:ubuntu20.04-cuda11.8-mmdeploy1.3.1 + +ARG DEBIAN_FRONTEND=noninteractive +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 +WORKDIR / + +RUN apt-get update && apt-get install -y --no-install-recommends feh + +RUN git clone https://github.com/open-mmlab/mmdeploy.git --depth=1 +RUN cd mmdeploy/; python3 tools/scripts/build_ubuntu_x64_ort.py + +# Install MMPose +ENV FORCE_CUDA="1" +ENV MMCV_WITH_OPS=1 +RUN pip3 install --upgrade --no-cache-dir openmim +RUN mim install mmengine +RUN mim install "mmcv>=2,<2.2.0" +RUN mim install "mmdet>=3" +RUN mim install "mmpose>=1.1.0" +# Fix an error when importing mmpose +RUN pip3 install --upgrade --no-cache-dir "numpy<2" scipy +RUN git clone --depth=1 --branch=main https://github.com/open-mmlab/mmpose.git + +RUN echo 'export PYTHONPATH=/mmdeploy/build/lib:$PYTHONPATH' >> ~/.bashrc +RUN echo 'export LD_LIBRARY_PATH=/mmdeploy/../mmdeploy-dep/onnxruntime-linux-x64-1.8.1/lib/:$LD_LIBRARY_PATH' >> ~/.bashrc + +# Show images +RUN apt-get update && apt-get install -y --no-install-recommends python3-tk + +WORKDIR /mmdeploy/ +CMD ["/bin/bash"] diff --git a/extras/mmdeploy/exports/.gitignore b/extras/mmdeploy/exports/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/extras/mmdeploy/exports/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/extras/mmdeploy/run_container.sh b/extras/mmdeploy/run_container.sh new file mode 100755 index 0000000..7353774 --- /dev/null +++ b/extras/mmdeploy/run_container.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +xhost + +docker run --privileged --rm --network host -it \ + --gpus all --shm-size=16g --ulimit memlock=-1 --ulimit stack=67108864 \ + --volume "$(pwd)"/:/RapidPoseTriangulation/ \ + --volume /tmp/.X11-unix:/tmp/.X11-unix \ + --env DISPLAY --env QT_X11_NO_MITSHM=1 \ + rpt_mmdeploy