初始化
推荐方式
已激活走 Open;出厂第一次 AiSession.Probe 后 Activate。明文走 OpenPlain。Submit 永不收激活码。
打开
AiInferPool.Open()
public static AiInferPool Open(
string containerPath,
string? preferProvider = null,
InferPoolOptions? options = null)
打开加密模型池。不收激活码。未激活走 Activate。options 为 null = workers=1、队列 64、Fail。
参数:
containerPath(string) —.darmodel路径(必填)preferProvider(string?) — 指名 Provider;null= 自动选options(InferPoolOptions?) — 池选项;null= 默认
返回值:
AiInferPool— 已打开的池
备注
MaxWorkers 合法 1..8,硬顶 8。GPU yolov8n 建议 1–2。一块 GPU 不要按图片数开会话。指名 Provider 不可用 = fail-closed。Windows 无 RKNN。
示例:
using var pool = AiInferPool.Open("inspect.darmodel", options: new InferPoolOptions
{
MaxWorkers = 2,
QueueCapacity = 64,
Overflow = InferOverflow.Fail,
});
AiInferPool.Activate()
public static AiInferPool Activate(
string containerPath,
string activationCode,
string? preferProvider = null,
InferPoolOptions? options = null)
出厂 / 试用:UI 只要一次码。之后本机或本进程 Open 免密。Submit 永不收码。
参数:
containerPath(string) —.darmodel路径(必填)activationCode(string) — 出厂激活码或试用码。空串抛AiPasswordRequiredExceptionpreferProvider(string?) — 指名 Provideroptions(InferPoolOptions?) — 池选项
返回值:
AiInferPool— 已打开的池
示例:
UnlockInfo u = AiSession.Probe("inspect.darmodel");
AiInferPool pool = u.NeedsCode
? AiInferPool.Activate("inspect.darmodel", code)
: AiInferPool.Open("inspect.darmodel");
AiInferPool.TryOpen()
public static bool TryOpen(
string containerPath,
out AiInferPool? pool,
out UnlockInfo info,
string? preferProvider = null,
InferPoolOptions? options = null)
不抛需要激活码。失败读 info.Display。内部走 AiSession.Probe。
参数:
containerPath(string) —.darmodel或明文模型路径pool(AiInferPool?) — 成功时池;失败为nullinfo(UnlockInfo) — 失败原因 / 激活状态preferProvider(string?) — 指名 Provideroptions(InferPoolOptions?) — 池选项
返回值:
bool— 是否打开成功
示例:
if (!AiInferPool.TryOpen("inspect.darmodel", out var pool, out UnlockInfo u))
{
Console.WriteLine(u.Display);
return;
}
using (pool) { }
AiInferPool.OpenPlain()
public static AiInferPool OpenPlain(
string modelPath,
string? preferProvider = null,
InferPoolOptions? options = null)
打开明文模型池。路径语义同 AiSession.OpenPlain:.onnx / .pdmodel(伴生 .pdiparams)/ 含二者的目录。
参数:
modelPath(string) — 明文模型路径preferProvider(string?) — 指名 Provideroptions(InferPoolOptions?) — 池选项
返回值:
AiInferPool— 已打开的池
备注
Paddle 是运行时载荷。.pt / .pth 仍拒,抛 AiUnsupportedPayloadException。
示例:
using var pool = AiInferPool.OpenPlain("model.onnx", options: new InferPoolOptions
{
MaxWorkers = 2,
});
AiInferPool.OpenWithKey()
public static AiInferPool OpenWithKey(
string containerPath,
string keyPath,
string? preferProvider = null,
InferPoolOptions? options = null)
旧双文件 .darmkey。新 DARB1 不要用。
参数:
containerPath(string) —.darmodel路径(必填)keyPath(string) —.darmkey路径(必填)preferProvider(string?) — 指名 Provideroptions(InferPoolOptions?) — 池选项
返回值:
AiInferPool— 已打开的池