测试环境:
onnxruntime==1.15.1
opencv-python==4.8.0.76
部分实现代码:
parser = argparse.ArgumentParser()
parser.add_argument("--model", type=str, default="yolov10n.onnx", help="Input your ONNX model.")
parser.add_argument("--img", type=str, default="bus.jpg", help="Path to input image.")
parser.add_argument("--conf-thres", type=float, default=0.5, help="Confidence threshold")
parser.add_argument("--iou-thres", type=float, default=0.5, help="NMS IoU threshold")
args = parser.parse_args()
# Create an instance of the YOLOv10 class with the specified arguments
detection = YOLOv10(args.model, args.img, args.conf_thres, args.iou_thres)
# Perform object detection and obtain the output image
output_image = detection.main()
# Display the output image in a window
cv2.namedWindow("Output", cv2.WINDOW_NORMAL)
cv2.imshow("Output", output_image)
# Wait for a key press to exit
cv2.waitKey(0)
视频演示:
代码下载:https://download.csdn.net/download/FL1623863129/89388835