benchmark模式用于分析YOLOv8
的各种导出格式的速度和准确性。基准提供了关于导出格式的大小、其mAP50-95
指标(用于目标检测和分割)或accuracy_top5
指标(用于分类)以及ONNX
、OpenVINO
、TensorRT
等各种导出格式中每张图像的毫秒推理时间的信息。这些信息可以帮助用户根据对速度和准确性的要求为其特定用例选择最佳导出格式。
from ultralytics.yolo.utils.benchmarks import benchmark
benchmark(model='yolov8n.pt', imgsz=640, half=False, device=0)
相关参数如下:
Key | Value | Description |
---|---|---|
model | None | path to model file, i.e. yolov8n.pt, yolov8n.yaml |
imgsz | 640 | image size as scalar or (h, w) list, i.e. (640, 480) |
half | False | FP16 quantization |
int8 | False | INT8 quantization |
device | None | device to run on, i.e. cuda device=0 or device=0,1,2,3 or device=cpu |
hard_fail | False | do not continue on error (bool), or val floor threshold (float) |