[Other] Update example codes using download_model api (#486)

* update example codes using download_model api

* add resource files to repo

* add resource files to repo

* fix

* reduce unused lib

* fix
This commit is contained in:
chenjian
2022-11-11 13:35:12 +08:00
committed by GitHub
parent b0a30a7b10
commit 0d0389f8d9
6 changed files with 63 additions and 12 deletions

View File

@@ -1,15 +1,17 @@
import fastdeploy as fd
import cv2
import fastdeploy as fd
import fastdeploy.utils
def parse_arguments():
import argparse
import ast
parser = argparse.ArgumentParser()
parser.add_argument(
"--model", required=True, help="Path of yolor onnx model.")
"--model", default=None, help="Path of yolor onnx model.")
parser.add_argument(
"--image", required=True, help="Path of test image file.")
"--image", default=None, help="Path of test image file.")
parser.add_argument(
"--device",
type=str,
@@ -39,10 +41,20 @@ args = parse_arguments()
# 配置runtime加载模型
runtime_option = build_option(args)
model = fd.vision.detection.YOLOR(args.model, runtime_option=runtime_option)
if args.model is None:
model = fd.download_model(name='YOLOR-W6')
else:
model = args.model
model = fd.vision.detection.YOLOR(model, runtime_option=runtime_option)
# 预测图片检测结果
im = cv2.imread(args.image)
if args.image is None:
image = fd.utils.get_detection_test_image()
else:
image = args.image
im = cv2.imread(image)
result = model.predict(im.copy())
print(result)