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

update detection example
This commit is contained in:
jm12138
2022-11-18 13:19:13 +08:00
committed by GitHub
parent 143506b654
commit 3848196829
15 changed files with 181 additions and 69 deletions

View File

@@ -7,9 +7,9 @@ def parse_arguments():
import ast
parser = argparse.ArgumentParser()
parser.add_argument(
"--model", required=True, help="Path of yolov6 onnx model.")
"--model", default=None, help="Path of yolov6 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='YOLOv6s')
else:
model = args.model
# 配置runtime加载模型
runtime_option = build_option(args)
model = fd.vision.detection.YOLOv6(args.model, runtime_option=runtime_option)
model = fd.vision.detection.YOLOv6(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)