mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
[Other] Update detection example codes using download_model api (#613)
update detection example
This commit is contained in:
@@ -7,9 +7,9 @@ def parse_arguments():
|
||||
import ast
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--model", required=True, help="Path of yolov7 onnx model.")
|
||||
"--model", default=None, help="Path of yolov7 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,
|
||||
@@ -37,12 +37,21 @@ def build_option(args):
|
||||
|
||||
args = parse_arguments()
|
||||
|
||||
if args.model is None:
|
||||
model = fd.download_model(name='YOLOv7')
|
||||
else:
|
||||
model = args.model
|
||||
|
||||
# 配置runtime,加载模型
|
||||
runtime_option = build_option(args)
|
||||
model = fd.vision.detection.YOLOv7(args.model, runtime_option=runtime_option)
|
||||
model = fd.vision.detection.YOLOv7(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())
|
||||
|
||||
# 预测结果可视化
|
||||
|
Reference in New Issue
Block a user