using OrpaonVision.Core.Results;
using OrpaonVision.SiteApp.Runtime.Contracts;
namespace OrpaonVision.SiteApp.Runtime.Services;
///
/// YOLO推理服务接口。
///
public interface IYoloInferenceService
{
///
/// 初始化模型。
///
Result Initialize();
///
/// 推理单张图像。
///
Result> Predict(byte[] imageData, int width, int height, string pixelFormat = "BGR8Packed");
///
/// 推理批量图像。
///
Result>> PredictBatch(
IReadOnlyList imageBatch,
IReadOnlyList<(int width, int height)> dimensions,
string pixelFormat = "BGR8Packed");
///
/// 获取支持的类别列表。
///
IReadOnlyList GetSupportedClasses();
///
/// 获取模型信息。
///
YoloModelInfo GetModelInfo();
///
/// 是否已初始化。
///
bool IsInitialized { get; }
///
/// 预热模型。
///
Result Warmup(int warmupCount = 3);
///
/// 释放资源。
///
void Dispose();
}
///
/// YOLO模型信息。
///
public sealed class YoloModelInfo
{
///
/// 模型名称。
///
public string ModelName { get; set; } = string.Empty;
///
/// 模型版本。
///
public string ModelVersion { get; set; } = string.Empty;
///
/// 输入尺寸。
///
public (int Width, int Height) InputSize { get; set; }
///
/// 支持的类别数量。
///
public int ClassCount { get; set; }
///
/// 类别名称列表。
///
public IReadOnlyList ClassNames { get; set; } = [];
///
/// 是否使用GPU。
///
public bool UseGpu { get; set; }
///
/// 推理时间(毫秒)。
///
public double InferenceTimeMs { get; set; }
///
/// 模型文件大小(字节)。
///
public long ModelFileSize { get; set; }
///
/// 加载时间(毫秒)。
///
public double LoadTimeMs { get; set; }
}