[Backend] Add KunlunXin XPU deploy support (#747)

* add xpu support

* fix docs

* update code

* update doc

* update code

* update yolov5

* update cmake

* add int64_t data support

* fix

* update download links

* add en doc

* update code

* update xpu options

* update doc

* update doc

* update doc

* update lib links

* update doc

* update code

* update lite xpu link

* update xpu lib

* update doc

* update en doc
This commit is contained in:
yeliang2258
2022-12-15 21:17:14 +08:00
committed by GitHub
parent 6e79df40d9
commit 5be839b322
39 changed files with 870 additions and 58 deletions

21
examples/vision/detection/yolov5/python/infer.py Normal file → Executable file
View File

@@ -1,20 +1,20 @@
import fastdeploy as fd
import cv2
import os
def parse_arguments():
import argparse
import ast
parser = argparse.ArgumentParser()
parser.add_argument(
"--model", default=None, help="Path of yolov5 onnx model.")
parser.add_argument("--model", default=None, help="Path of yolov5 model.")
parser.add_argument(
"--image", default=None, help="Path of test image file.")
parser.add_argument(
"--device",
type=str,
default='cpu',
help="Type of inference device, support 'cpu' or 'gpu'.")
help="Type of inference device, support 'cpu' or 'gpu' or 'xpu'.")
parser.add_argument(
"--use_trt",
type=ast.literal_eval,
@@ -25,6 +25,8 @@ def parse_arguments():
def build_option(args):
option = fd.RuntimeOption()
if args.device.lower() == "xpu":
option.use_xpu()
if args.device.lower() == "gpu":
option.use_gpu()
@@ -37,14 +39,15 @@ def build_option(args):
args = parse_arguments()
if args.model is None:
model = fd.download_model(name='YOLOv5s')
else:
model = args.model
# 配置runtime加载模型
runtime_option = build_option(args)
model = fd.vision.detection.YOLOv5(model, runtime_option=runtime_option)
model_file = os.path.join(args.model, "model.pdmodel")
params_file = os.path.join(args.model, "model.pdiparams")
model = fd.vision.detection.YOLOv5(
model_file,
params_file,
runtime_option=runtime_option,
model_format=fd.ModelFormat.PADDLE)
# 预测图片检测结果
if args.image is None: