Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.75 KB

python.md

File metadata and controls

54 lines (37 loc) · 1.75 KB

Python Deployment

Make sure that FastDeploy is installed in the development environment. Refer to FastDeploy Installation to install the pre-built FastDeploy, or build and install according to your own needs.

This document uses the PaddleDetection target detection model PPYOLOE as an example to show an inference example on the CPU.

1. Get the Model and Test Image

import fastdeploy as fd

model_url = "https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz"
image_url = "https://bj.bcebos.com/fastdeploy/tests/test_det.jpg"
fd.download_and_decompress(model_url, path=".")
fd.download(image_url, path=".")

2. Load Model

model_file = "ppyoloe_crn_l_300e_coco/model.pdmodel"
params_file = "ppyoloe_crn_l_300e_coco/model.pdiparams"
infer_cfg_file = "ppyoloe_crn_l_300e_coco/infer_cfg.yml"
model = fd.vision.detection.PPYOLOE(model_file, params_file, infer_cfg_file)

3. Get Prediction for Image Object Detection

import cv2
im = cv2.imread("000000014439.jpg")

result = model.predict(im)
print(result)

4. Visualize image prediction results

vis_im = fd.vision.visualize.vis_detection(im, result, score_threshold=0.5)
cv2.imwrite("vis_image.jpg", vis_im)

After the visualization is executed, open vis_image.jpg and the visualization effect is as follows:

other documents