mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-11-02 04:43:27 +08:00
English | 简体中文
BlazeFace Python Deployment Example
Before deployment, two steps require confirmation
-
- Software and hardware should meet the requirements. Please refer to FastDeploy Environment Requirements
-
- Install FastDeploy Python whl package. Refer to FastDeploy Python Installation
This directory provides examples that infer.py fast finishes the deployment of BlazeFace on CPU/GPU.
# Download the example code for deployment
git clone https://github.com/PaddlePaddle/FastDeploy.git
cd examples/vision/facedet/blazeface/python/
# Download BlazeFace model files and test images
wget https://raw.githubusercontent.com/DefTruth/lite.ai.toolkit/main/examples/lite/resources/test_lite_face_detector_3.jpg
wget https://bj.bcebos.com/paddlehub/fastdeploy/blazeface-1000e.tgz
# Use blazeface-1000e model
# CPU Inference
python infer.py --model blazeface-1000e/ --image test_lite_face_detector_3.jpg --device cpu
# GPU Inference
python infer.py --model blazeface-1000e/ --image test_lite_face_detector_3.jpg --device gpu
The visualized result after running is as follows
BlazeFace Python Interface
fastdeploy.vision.facedet.BlzaeFace(model_file, params_file=None, runtime_option=None, config_file=None, model_format=ModelFormat.PADDLE)
BlazeFace model loading and initialization, among which model_file is the exported PADDLE model format
Parameter
- model_file(str): Model file path
- params_file(str): Parameter file path. No need to set when the model is in PADDLE format
- config_file(str): config file path. No need to set when the model is in PADDLE format
- runtime_option(RuntimeOption): Backend inference configuration. None by default, which is the default configuration
- model_format(ModelFormat): Model format. PADDLE format by default
predict function
BlazeFace.predict(input_image)Through let BlazeFace.postprocessor.conf_threshold = 0.2,to modify conf_threshold
Model prediction interface. Input images and output detection results.
Parameter
- input_image(np.ndarray): Input image in HWC or BGR format
Return
Return
fastdeploy.vision.FaceDetectionResultstructure. Refer to Vision Model Prediction Results for its description.