Class OnnxSessionFactory
- Namespace
- VisioForge.Core.AI
- Assembly
- VisioForge.Core.AI.dll
Builds Microsoft.ML.OnnxRuntime.SessionOptions with the same execution-provider selection and bundled-native preload logic used by VisioForge.Core.AI.OnnxInferenceEngine, for the multi-stage OCR pipeline that owns its own per-stage Microsoft.ML.OnnxRuntime.InferenceSession instances (detector, angle classifier, recognizer).
public static class OnnxSessionFactoryInheritance
Inherited Members
Remarks
The OCR stages cannot share VisioForge.Core.AI.OnnxInferenceEngine directly because each uses a different preprocessing path (ImageNet normalization for the detector, midgray-padded crops for the recognizer) and dynamic input shapes. They still want the hard-won provider selection (Auto resolves to the best provider actually compiled into the loaded native build) and the Windows DirectML preload, so that logic lives here and is reused by both.
Methods
CreateSessionOptions(OnnxExecutionProvider, int, BaseContext, out OnnxExecutionProvider)
Creates session options configured with the requested execution provider (CPU fallback always appended) and extended graph optimization. Best-effort: an unavailable hardware provider falls back to CPU with a warning.
public static SessionOptions CreateSessionOptions(OnnxExecutionProvider provider, int deviceId, BaseContext context, out OnnxExecutionProvider activeProvider)Parameters
providerOnnxExecutionProvider-
The requested execution provider; VisioForge.Core.Types.X.AI.OnnxExecutionProvider.Auto resolves to the fastest available.
deviceIdint-
The hardware device id for CUDA / DirectML.
contextBaseContext-
Optional logging context.
activeProviderOnnxExecutionProvider-
Receives the provider that was actually engaged.
Returns
- SessionOptions
-
The configured Microsoft.ML.OnnxRuntime.SessionOptions. The caller owns and must dispose it.