These two demonstrations show how to inference PaddlePaddle model using OpenCV.
pip install paddlepaddle-gpu
pip install paddlehub
pip install paddle2onnx
Run the code sample as follows:
python paddle_resnet50.py
There are three parts to the process:
cv2.dnn.readNetFromONNX
to load the model file.For more details, please refer to PaddleSeg.
wget https://x2paddle.bj.bcebos.com/inference/models/humanseg_hrnet18_small_v1.zip
unzip humanseg_hrnet18_small_v1.zip
Notes:
To convert the model, use the following command:
paddle2onnx --model_dir humanseg_hrnet18_small_v1 \
--model_filename model.pdmodel \
--params_filename model.pdiparams \
--opset_version 11 \
--save_file humanseg_hrnet18_tiny.onnx
The converted model can be found in the current directory by the name humanseg_hrnet18_tiny.onnx
.
Run the code sample as follows:
python paddle_humanseg.py
There are three parts to the process:
cv2.dnn.readNetFromONNX
to load the model file.The resulting file can be found at data/result_test_human.jpg
.