This section describes how to use the tools/export_model.py
script to export models.
| Input Name | Input Shape | Meaning | | :----------: | --------------- | ------------------------------------------------------------------------------------------------------------------------- | | image | [None, 3, H, W] | Enter the network image. None indicates the Batch dimension. If the input image size is variable length, H and W are None | | im_shape | [None, 2] | The size of the image after resize is expressed as H,W, and None represents the Batch dimension | | scale_factor | [None, 2] | The input image size is larger than the real image size, denoted byscale_y, scale_x |
AttentionFor details about the preprocessing method, see the Test Reader section in the configuration file.
-The output of the dynamic and static derived model in Paddle Detection is unified as follows:
AttentionThe model-to-static export does not support cases where numpy operations are included in the model structure.
FLAG | USE | DEFAULT | NOTE |
---|---|---|---|
-c | Specifying a configuration file | None | |
--output_dir | Model save path | ./output_inference |
The model is saved in the output/default_file_name/ path by default |
Using the trained model for trial use, the script is as follows:
# The YOLOv3 model is exported
python tools/export_model.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml --output_dir=./inference_model \
-o weights=weights/yolov3_darknet53_270e_coco.pdparams
The prediction model will be exported to the inference_model/yolov3_darknet53_270e_coco
directory. infer_cfg.yml
, model.pdiparams
, model.pdiparams.info
, model.pdmodel
respectively.
When using Fluid TensorRT for prediction, since <= TensorRT 5.1 only supports fixed-length input, the image size of the data
layer of the saved model needs to be the same as the actual input image size. Fluid C++ prediction engine does not have this limitation. Setting image_shape
in Test Reader changes the size of the input image in the saved model. The following is an example:
#Export the YOLOv3 model with the input 3x640x640
python tools/export_model.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml --output_dir=./inference_model \
-o weights=weights/yolov3_darknet53_270e_coco.pdparams TestReader.inputs_def.image_shape=[3,640,640]