MaochengHu 576cda45b8 first commit | 2 years ago | |
---|---|---|
.. | ||
CMakeLists.txt | 2 years ago | |
CMakeLists_armv8.txt | 2 years ago | |
README.md | 2 years ago | |
keypoint_detector.cpp | 2 years ago | |
keypoint_detector.h | 2 years ago | |
keypoint_postprocess.cpp | 2 years ago | |
keypoint_postprocess.h | 2 years ago | |
main.cpp | 2 years ago | |
picodet_mnn.cpp | 2 years ago | |
picodet_mnn.h | 2 years ago |
This fold provides PicoDet+TinyPose inference code using Alibaba's MNN framework. Most of the implements in this fold are same as demo_ncnn.
Just run:
pip install MNN
Please follow the official document to build MNN engine.
Create picodet_m_416_coco.onnx and tinypose256.onnx example:
modelName=picodet_m_416_coco
# export model
python tools/export_model.py \
-c configs/picodet/${modelName}.yml \
-o weights=${modelName}.pdparams \
--output_dir=inference_model
# convert to onnx
paddle2onnx --model_dir inference_model/${modelName} \
--model_filename model.pdmodel \
--params_filename model.pdiparams \
--opset_version 11 \
--save_file ${modelName}.onnx
# onnxsim
python -m onnxsim ${modelName}.onnx ${modelName}_processed.onnx
shell
python -m MNN.tools.mnnconvert -f ONNX --modelFile picodet-416.onnx --MNNModel picodet-416.mnn
Here are converted model picodet_m_416. tinypose256
For C++ code, replace libMNN.so
under ./mnn/lib with the one you just compiled, modify OpenCV path and MNN path at CMake file,
and run
mkdir build && cd build
cmake ..
make
Note that a flag at main.cpp
is used to control whether to show the detection result or save it into a fold.
#define __SAVE_RESULT__ // if defined save drawed results to ../results, else show it in windows
Prepare OpenCV library OpenCV_4_1.
mkdir third && cd third
wget https://paddle-inference-dist.bj.bcebos.com/opencv4.1.0.tar.gz
tar -zxvf opencv4.1.0.tar.gz
cd ..
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-21 -DANDROID_TOOLCHAIN=gcc ..
make
To detect images in a fold, run:
./tinypose-mnn [mode] [image_file]
param | detail |
---|---|
--mode | input mode,0:camera;1:image;2:video;3:benchmark |
--image_file | input image path |
for example:
./tinypose-mnn "1" "../imgs/test.jpg"
For speed benchmark:
./tinypose-mnn "3" "0"
Plateform: Kirin980 Model: tinypose256
param | Min(s) | Max(s) | Avg(s) |
---|---|---|---|
Thread=4 | 0.018 | 0.021 | 0.019 |
Thread=1 | 0.031 | 0.041 | 0.032 |