convert pytorch trained yolo model to ncnn for Flexible deployment
We use pytorch_0.2 to train our model, it's advantages are very flexible. Then we use PytorchConvert convert our model to ncnn.
ncnn is a high-performance neural network inference computing framework optimized for mobile platforms. With it, we can easily deploy deep learning algorithm models to the mobile platform.
-
train yolov1 model, we use this reposity pytorch-YOLO-v1, attention, we must use ceil_mode=True when pooling is used.
-
Convert model
-
check the output is correct or not, write decoder in c/c++
step1
cd pytorch-yolo-v1
python train.py
best.pth will produced in /pytorch-yolo-v1
step2
cd pytorchConvert/code
python run.py
converted model will in /pytorchConvert/ModelFiles/ResNet/
our model name is ResNet, because we use resnet50 as backbone, and I forget change class name, anyway, rename it to yolo1.param and yolo1.bin
step3
cd ncnn
mkdir build
cd build
cmake ..
make -j4
uncomment add_subdirectory(examples) in ncnn/CMakeLists.txt
cd build
cmake ..
make -j4
copy yolo1.param yolo1.bin to build/examples
cd build
cd examples
./xiong_yolo1 person.jpg