主题
ModelInfo 与 ModelConfig 说明
YOLO 模块将 模型元数据 与 推理调参 拆分为两个接口,均返回 PascalCase JSON,须 FreeStringPtr 释放。
| 接口 | 用途 |
|------|------|
| YoloGetModelInfo / YoloListModels | 模型路径、输入尺寸、类别表、EP、任务类型等 |
| YoloGetModelConfig / YoloSetModelConfig / YoloSetModelConfigByKey | 置信度、NMS、TopK、类别过滤等 |
JSON 键使用 PascalCase(大小写不敏感)。规则见 JSON配置解析约定。
ModelInfo 主要字段
| 字段 | 说明 |
|------|------|
| Success | 查询是否成功 |
| ModelHandle | 模型句柄 |
| ModelPath | 模型文件路径 |
| BinPath | NCNN 时 .bin 路径(有则输出) |
| LabelsPath | 类别名文件路径 |
| ModelType | Onnx / Ncnn / Trt |
| ModelTypeCode | 0 Engine / 1 ONNX / 2 NCNN |
| InferenceType | Detect / Classify / Segment / Pose / Obb |
| InferenceTypeCode | 0–4,与加载 API 的 inferenceType 一致 |
| InputWidth / InputHeight | 模型输入尺寸 |
| DeviceIndex | 加载时请求的设备索引(-1=CPU) |
| InferenceDevice | 展示用 CPU / GPU0… |
| ClassNameCount / ClassNames | 类别数量与名称表 |
| ExecutionProvider | 运行时 EP 名称 |
| AvailableProviders | 可用 EP 列表 |
| Active / Loaded | 运行时状态 |
推理结果 JSON 使用
TaskType;ModelInfo 使用InferenceType(语义相同,命名区分用途)。
ModelConfig 字段(Set / Get 共用)
Set 时未出现的键保持不变。
| 字段 | 类型 | 说明 |
|------|------|------|
| Confidence | number | 置信度阈值 |
| ConfThreshold | number | 置信度阈值别名 |
| ScoreThreshold | number | 分数阈值 |
| Iou | number | IoU 阈值 |
| IouThreshold | number | NMS IoU 阈值 |
| NmsThreshold | number | NMS 阈值 |
| MaxDetections | int | 最大检测数 |
| TopK | int | Top-K(Classify) |
| NumClasses | int | 类别数 |
| KeypointCount | int | 关键点数 |
| ClassAwareNms | bool | 分类感知 NMS |
| MaskFormat | string | 掩码格式 |
| IncludeMasks | bool | 是否输出掩码 |
| Classes | array | 类别过滤 |
| ClassesFilter | array | 类别过滤别名 |
有效字段因 InferenceType 而异(未设置的键可能不出现)。与推理 API 参数对应关系见 推理输入参数说明。
未调用过 YoloSetModelConfig 时,YoloGetModelConfig 可能仅返回 {"Success":true}。
示例
YoloGetModelInfo
json
{
"Success": true,
"ModelHandle": 1000,
"ModelPath": "D:\\models\\yolo11n-cls.onnx",
"ModelType": "Onnx",
"InferenceType": "Classify",
"InputWidth": 224,
"InputHeight": 224,
"DeviceIndex": -1,
"InferenceDevice": "CPU"
}YoloSetModelConfig / YoloGetModelConfig
json
{
"Success": true,
"Confidence": 0.5,
"IouThreshold": 0.45,
"MaxDetections": 100
}单键设置
cpp
YoloSetModelConfigByKey(ola, h, "Confidence", "0.6");