LearningModel.LoadFromStorageFileAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| LoadFromStorageFileAsync(IStorageFile, ILearningModelOperatorProvider) |
Important For the latest documentation about Windows Machine Learning, see What is Windows ML. That documentation describes APIs that are in the Microsoft.Windows.AI.MachineLearning namespace, which ships in the Windows App SDK. Those APIs supersede the ones documented here, which are in the Windows.AI.MachineLearning namespace, and were shipped in 2018. Loads an ONNX model from an IStorageFile asynchronously. |
| LoadFromStorageFileAsync(IStorageFile) |
Important For the latest documentation about Windows Machine Learning, see What is Windows ML. That documentation describes APIs that are in the Microsoft.Windows.AI.MachineLearning namespace, which ships in the Windows App SDK. Those APIs supersede the ones documented here, which are in the Windows.AI.MachineLearning namespace, and were shipped in 2018. Loads an ONNX model from an IStorageFile asynchronously. |
LoadFromStorageFileAsync(IStorageFile, ILearningModelOperatorProvider)
Important
For the latest documentation about Windows Machine Learning, see What is Windows ML. That documentation describes APIs that are in the Microsoft.Windows.AI.MachineLearning namespace, which ships in the Windows App SDK. Those APIs supersede the ones documented here, which are in the Windows.AI.MachineLearning namespace, and were shipped in 2018.
Loads an ONNX model from an IStorageFile asynchronously.
public:
static IAsyncOperation<LearningModel ^> ^ LoadFromStorageFileAsync(IStorageFile ^ modelFile, ILearningModelOperatorProvider ^ operatorProvider);
/// [Windows.Foundation.Metadata.Overload("LoadFromStorageFileWithOperatorProviderAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
static IAsyncOperation<LearningModel> LoadFromStorageFileAsync(IStorageFile const& modelFile, ILearningModelOperatorProvider const& operatorProvider);
[Windows.Foundation.Metadata.Overload("LoadFromStorageFileWithOperatorProviderAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<LearningModel> LoadFromStorageFileAsync(IStorageFile modelFile, ILearningModelOperatorProvider operatorProvider);
function loadFromStorageFileAsync(modelFile, operatorProvider)
Public Shared Function LoadFromStorageFileAsync (modelFile As IStorageFile, operatorProvider As ILearningModelOperatorProvider) As IAsyncOperation(Of LearningModel)
Parameters
- modelFile
- IStorageFile
The location of the model file.
- operatorProvider
- ILearningModelOperatorProvider
Returns
A LearningModel based on the model file.
- Attributes
Remarks
Windows Server
To use this API on Windows Server, you must use Windows Server 2019 with Desktop Experience.
Thread safety
This API is thread-safe.
Applies to
LoadFromStorageFileAsync(IStorageFile)
Important
For the latest documentation about Windows Machine Learning, see What is Windows ML. That documentation describes APIs that are in the Microsoft.Windows.AI.MachineLearning namespace, which ships in the Windows App SDK. Those APIs supersede the ones documented here, which are in the Windows.AI.MachineLearning namespace, and were shipped in 2018.
Loads an ONNX model from an IStorageFile asynchronously.
public:
static IAsyncOperation<LearningModel ^> ^ LoadFromStorageFileAsync(IStorageFile ^ modelFile);
/// [Windows.Foundation.Metadata.Overload("LoadFromStorageFileAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
static IAsyncOperation<LearningModel> LoadFromStorageFileAsync(IStorageFile const& modelFile);
[Windows.Foundation.Metadata.Overload("LoadFromStorageFileAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<LearningModel> LoadFromStorageFileAsync(IStorageFile modelFile);
function loadFromStorageFileAsync(modelFile)
Public Shared Function LoadFromStorageFileAsync (modelFile As IStorageFile) As IAsyncOperation(Of LearningModel)
Parameters
- modelFile
- IStorageFile
The location of the model file.
Returns
A LearningModel based on the model file.
- Attributes
Examples
The following example loads the model and creates an evaulation session with it.
private async Task LoadModelAsync(string _modelFileName)
{
LearningModel _model;
LearningModelSession _session;
try
{
// Load and create the model
var modelFile =
await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/{_modelFileName}"));
_model = await LearningModel.LoadFromStorageFileAsync(modelFile);
// Create the evaluation session with the model
_session = new LearningModelSession(_model);
}
catch (Exception ex)
{
StatusBlock.Text = $"error: {ex.Message}";
_model = null;
}
}
Remarks
Windows Server
To use this API on Windows Server, you must use Windows Server 2019 with Desktop Experience.
Thread safety
This API is thread-safe.