本节博客,我们继续讲解,如何在cpu+windows上,跑通自己的实例分割模型。
目录
模型
类别名称
量化
导出模型
拉取最新代码
进入官网ultralytics
模型
该项目包括存储在 models
和 quantized_models
目录中的各种预训练标准 YOLO 模型:
模型类型 | 模型名称 |
---|---|
标准模型 | yolo5-n6.onnx |
yolo7-tiny.onnx | |
yolo8n.onnx | |
yolo8n-seg.onnx | |
yolo10n.onnx | |
yolo11n.onnx | |
yolo11n-seg.onnx | |
量化模型 | yolo5-n6_uint8.onnx |
yolo7-tiny-uint8.onnx | |
yolo8n_uint8.onnx | |
yolo8n-seg_uint8.onnx | |
yolo10n_uint8.onnx | |
yolo11n_uint8.onnx | |
yolo11n-seg_uint8.onnx |
你也可以使用带有自定义类别的自定义 YOLO 版本!
比如,我们用ultralytics训练好的实例分割模型best.pt,我们再用原生的ultralytics转onnx方式,转为best.onnx。如下:
类别名称
-
coco.names:包含模型所使用的类别标签列表。
这里,我们也要修改coco.names,改为自己的标签!
量化
quantized_models
目录中包含针对低精度推理优化的 YOLO 模型的量化版本。此外,quantized_models/yolos_quantization.py
脚本可用于对自定义 YOLO 模型进行自定义量化。
注意:量化模型具有模型体积更小的优势,并且在准确性略有下降的情况下,可能实现更快的推理速度。
我们先不量化试一下:
修改源码:
然后,点击重新生成!
并且,运行exe,但是,你会发现,没有出结果。
怎么办呢?我们查看项目源码,发现,后来支持了seg:
但是,源码还是det【目标检测】。
因此,我们将源码从原始代码:
/**
* @file image_inference.cpp
* @brief Object detection in a static image using YOLO models (v5, v7, v8, v10).
*
* This file implements an object detection application that utilizes YOLO
* (You Only Look Once) models, specifically versions 5, 7, 8, and 10.
* The application loads a specified image, processes it to detect objects,
* and displays the results with bounding boxes around detected objects.
*
* The application supports the following functionality:
* - Loading a specified image from disk.
* - Initializing the YOLO detector with the desired model and labels.
* - Detecting objects within the image.
* - Drawing bounding boxes around detected objects and displaying the result.
*
* Configuration parameters can be adjusted to suit specific requirements:
* - `isGPU`: Set to true to enable GPU processing for improved performance;
* set to false for CPU processing.
* - `labelsPath`: Path to the class labels file (e.g., COCO dataset