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
|
import ast
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model", required=True, help="Path of nanodet_plus onnx model.")
|
"--model", default=None, help="Path of nanodet_plus onnx model.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -37,13 +37,21 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
|
if args.model is None:
|
||||||
|
model = fd.download_model(name='NanoDetPlus_320')
|
||||||
|
else:
|
||||||
|
model = args.model
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
model = fd.vision.detection.NanoDetPlus(
|
model = fd.vision.detection.NanoDetPlus(model, runtime_option=runtime_option)
|
||||||
args.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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -9,10 +9,10 @@ def parse_arguments():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model_dir",
|
"--model_dir",
|
||||||
required=True,
|
default=None,
|
||||||
help="Path of PaddleDetection model directory")
|
help="Path of PaddleDetection model directory")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -41,9 +41,14 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
model_file = os.path.join(args.model_dir, "model.pdmodel")
|
if args.model_dir is None:
|
||||||
params_file = os.path.join(args.model_dir, "model.pdiparams")
|
model_dir = fd.download_model(name='faster_rcnn_r50_vd_fpn_2x_coco')
|
||||||
config_file = os.path.join(args.model_dir, "infer_cfg.yml")
|
else:
|
||||||
|
model_dir = args.model_dir
|
||||||
|
|
||||||
|
model_file = os.path.join(model_dir, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_dir, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_dir, "infer_cfg.yml")
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
@@ -51,7 +56,11 @@ model = fd.vision.detection.FasterRCNN(
|
|||||||
model_file, params_file, config_file, runtime_option=runtime_option)
|
model_file, params_file, config_file, 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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -9,10 +9,10 @@ def parse_arguments():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model_dir",
|
"--model_dir",
|
||||||
required=True,
|
default=None,
|
||||||
help="Path of PaddleDetection model directory")
|
help="Path of PaddleDetection model directory")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -48,9 +48,14 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
model_file = os.path.join(args.model_dir, "model.pdmodel")
|
if args.model_dir is None:
|
||||||
params_file = os.path.join(args.model_dir, "model.pdiparams")
|
model_dir = fd.download_model(name='mask_rcnn_r50_1x_coco')
|
||||||
config_file = os.path.join(args.model_dir, "infer_cfg.yml")
|
else:
|
||||||
|
model_dir = args.model_dir
|
||||||
|
|
||||||
|
model_file = os.path.join(model_dir, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_dir, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_dir, "infer_cfg.yml")
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
@@ -58,7 +63,11 @@ model = fd.vision.detection.MaskRCNN(
|
|||||||
model_file, params_file, config_file, runtime_option=runtime_option)
|
model_file, params_file, config_file, 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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -9,10 +9,10 @@ def parse_arguments():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model_dir",
|
"--model_dir",
|
||||||
required=True,
|
default=None,
|
||||||
help="Path of PaddleDetection model directory")
|
help="Path of PaddleDetection model directory")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -39,9 +39,14 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
model_file = os.path.join(args.model_dir, "model.pdmodel")
|
if args.model_dir is None:
|
||||||
params_file = os.path.join(args.model_dir, "model.pdiparams")
|
model_dir = fd.download_model(name='picodet_l_320_coco_lcnet')
|
||||||
config_file = os.path.join(args.model_dir, "infer_cfg.yml")
|
else:
|
||||||
|
model_dir = args.model_dir
|
||||||
|
|
||||||
|
model_file = os.path.join(model_dir, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_dir, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_dir, "infer_cfg.yml")
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
@@ -49,7 +54,11 @@ model = fd.vision.detection.PicoDet(
|
|||||||
model_file, params_file, config_file, runtime_option=runtime_option)
|
model_file, params_file, config_file, 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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -9,10 +9,10 @@ def parse_arguments():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model_dir",
|
"--model_dir",
|
||||||
required=True,
|
default=None,
|
||||||
help="Path of PaddleDetection model directory")
|
help="Path of PaddleDetection model directory")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -41,9 +41,14 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
model_file = os.path.join(args.model_dir, "model.pdmodel")
|
if args.model_dir is None:
|
||||||
params_file = os.path.join(args.model_dir, "model.pdiparams")
|
model_dir = fd.download_model(name='ppyolo_r50vd_dcn_1x_coco')
|
||||||
config_file = os.path.join(args.model_dir, "infer_cfg.yml")
|
else:
|
||||||
|
model_dir = args.model_dir
|
||||||
|
|
||||||
|
model_file = os.path.join(model_dir, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_dir, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_dir, "infer_cfg.yml")
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
@@ -51,7 +56,11 @@ model = fd.vision.detection.PPYOLO(
|
|||||||
model_file, params_file, config_file, runtime_option=runtime_option)
|
model_file, params_file, config_file, 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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -2,7 +2,6 @@ import cv2
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import fastdeploy as fd
|
import fastdeploy as fd
|
||||||
import fastdeploy.utils
|
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
|
@@ -9,10 +9,10 @@ def parse_arguments():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model_dir",
|
"--model_dir",
|
||||||
required=True,
|
default=None,
|
||||||
help="Path of PaddleDetection model directory")
|
help="Path of PaddleDetection model directory")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -39,9 +39,14 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
model_file = os.path.join(args.model_dir, "model.pdmodel")
|
if args.model_dir is None:
|
||||||
params_file = os.path.join(args.model_dir, "model.pdiparams")
|
model_dir = fd.download_model(name='yolov3_darknet53_270e_coco')
|
||||||
config_file = os.path.join(args.model_dir, "infer_cfg.yml")
|
else:
|
||||||
|
model_dir = args.model_dir
|
||||||
|
|
||||||
|
model_file = os.path.join(model_dir, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_dir, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_dir, "infer_cfg.yml")
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
@@ -49,7 +54,11 @@ model = fd.vision.detection.YOLOv3(
|
|||||||
model_file, params_file, config_file, runtime_option=runtime_option)
|
model_file, params_file, config_file, 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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -9,10 +9,10 @@ def parse_arguments():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model_dir",
|
"--model_dir",
|
||||||
required=True,
|
default=None,
|
||||||
help="Path of PaddleDetection model directory")
|
help="Path of PaddleDetection model directory")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -39,9 +39,14 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
model_file = os.path.join(args.model_dir, "model.pdmodel")
|
if args.model_dir is None:
|
||||||
params_file = os.path.join(args.model_dir, "model.pdiparams")
|
model_dir = fd.download_model(name='yolox_s_300e_coco')
|
||||||
config_file = os.path.join(args.model_dir, "infer_cfg.yml")
|
else:
|
||||||
|
model_dir = args.model_dir
|
||||||
|
|
||||||
|
model_file = os.path.join(model_dir, "model.pdmodel")
|
||||||
|
params_file = os.path.join(model_dir, "model.pdiparams")
|
||||||
|
config_file = os.path.join(model_dir, "infer_cfg.yml")
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
@@ -49,7 +54,11 @@ model = fd.vision.detection.PaddleYOLOX(
|
|||||||
model_file, params_file, config_file, runtime_option=runtime_option)
|
model_file, params_file, config_file, 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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -7,9 +7,9 @@ def parse_arguments():
|
|||||||
import ast
|
import ast
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model", required=True, help="Path of scaledyolov4 onnx model.")
|
"--model", default=None, help="Path of scaledyolov4 onnx model.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -37,13 +37,21 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
|
if args.model is None:
|
||||||
|
model = fd.download_model(name='ScaledYOLOv4-P5')
|
||||||
|
else:
|
||||||
|
model = args.model
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
model = fd.vision.detection.ScaledYOLOv4(
|
model = fd.vision.detection.ScaledYOLOv4(model, runtime_option=runtime_option)
|
||||||
args.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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
import fastdeploy as fd
|
import fastdeploy as fd
|
||||||
import fastdeploy.utils
|
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
|
@@ -7,9 +7,9 @@ def parse_arguments():
|
|||||||
import ast
|
import ast
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model", required=True, help="Path of yolov5 onnx model.")
|
"--model", default=None, help="Path of yolov5 onnx model.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -37,12 +37,21 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
|
if args.model is None:
|
||||||
|
model = fd.download_model(name='YOLOv5s')
|
||||||
|
else:
|
||||||
|
model = args.model
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
model = fd.vision.detection.YOLOv5(args.model, runtime_option=runtime_option)
|
model = fd.vision.detection.YOLOv5(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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -7,9 +7,9 @@ def parse_arguments():
|
|||||||
import ast
|
import ast
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model", required=True, help="Path of yolov5lite onnx model.")
|
"--model", default=None, help="Path of yolov5lite onnx model.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -37,13 +37,21 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
|
if args.model is None:
|
||||||
|
model = fd.download_model(name='YOLOv5Lite-s')
|
||||||
|
else:
|
||||||
|
model = args.model
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
model = fd.vision.detection.YOLOv5Lite(
|
model = fd.vision.detection.YOLOv5Lite(model, runtime_option=runtime_option)
|
||||||
args.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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -7,9 +7,9 @@ def parse_arguments():
|
|||||||
import ast
|
import ast
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model", required=True, help="Path of yolov6 onnx model.")
|
"--model", default=None, help="Path of yolov6 onnx model.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -37,12 +37,21 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
|
if args.model is None:
|
||||||
|
model = fd.download_model(name='YOLOv6s')
|
||||||
|
else:
|
||||||
|
model = args.model
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
|
@@ -7,9 +7,9 @@ def parse_arguments():
|
|||||||
import ast
|
import ast
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model", required=True, help="Path of yolov7 onnx model.")
|
"--model", default=None, help="Path of yolov7 onnx model.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -37,12 +37,21 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
|
if args.model is None:
|
||||||
|
model = fd.download_model(name='YOLOv7')
|
||||||
|
else:
|
||||||
|
model = args.model
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
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())
|
result = model.predict(im.copy())
|
||||||
|
|
||||||
# 预测结果可视化
|
# 预测结果可视化
|
||||||
|
@@ -7,9 +7,9 @@ def parse_arguments():
|
|||||||
import ast
|
import ast
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--model", required=True, help="Path of yolox onnx model.")
|
"--model", default=None, help="Path of yolox onnx model.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--image", required=True, help="Path of test image file.")
|
"--image", default=None, help="Path of test image file.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
type=str,
|
type=str,
|
||||||
@@ -37,12 +37,21 @@ def build_option(args):
|
|||||||
|
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
|
if args.model is None:
|
||||||
|
model = fd.download_model(name='YOLOX-s')
|
||||||
|
else:
|
||||||
|
model = args.model
|
||||||
|
|
||||||
# 配置runtime,加载模型
|
# 配置runtime,加载模型
|
||||||
runtime_option = build_option(args)
|
runtime_option = build_option(args)
|
||||||
model = fd.vision.detection.YOLOX(args.model, runtime_option=runtime_option)
|
model = fd.vision.detection.YOLOX(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())
|
result = model.predict(im.copy())
|
||||||
print(result)
|
print(result)
|
||||||
# 预测结果可视化
|
# 预测结果可视化
|
||||||
|
Reference in New Issue
Block a user