mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
[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:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user