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