ModelLoader

Helpers & Utilities · AiDotNet.Helpers

Provides static methods for loading self-describing AIMF model files with automatic type detection.

How It Works

For Beginners: When you save a model using the new AIMF envelope format, the file contains metadata about what type of model it is. ModelLoader reads this metadata and automatically creates the correct model instance, so you don’t need to know the exact model type in advance.

Example usage:

All model files must use the AIMF envelope format. Files saved with SaveModel() automatically include the AIMF header.

Methods

Method Summary
IModelSerializer Load(string filePath, string licenseKey, byte[] decryptionToken) Loads a self-describing AIMF model file, automatically detecting and instantiating the correct model type.
IModelSerializer LoadFromBytes(byte[] data, string licenseKey, byte[] decryptionToken) Loads a self-describing AIMF model from a byte array.
ModelFileInfo Inspect(string filePath) Reads only the header of an AIMF model file without loading the full model.
bool IsSelfDescribing(string filePath) Checks whether a file is a self-describing AIMF model file by reading only the first 4 bytes.
void SaveEncrypted(IModelSerializer model, string filePath, string licenseKey, int[] inputShape, int[] outputShape, SerializationFormat format, DynamicShapeInfo dynamicShapeInfo, byte[] decryptionToken) Saves a model to an encrypted AIMF file that requires a license key to load.