共用方式為


LearningModel.LoadFromStorageFileAsync 方法

定義

多載

LoadFromStorageFileAsync(IStorageFile, ILearningModelOperatorProvider)

以非同步方式從 IStorageFile 載入 ONNX 模型。

LoadFromStorageFileAsync(IStorageFile)

以非同步方式從 IStorageFile 載入 ONNX 模型。

LoadFromStorageFileAsync(IStorageFile, ILearningModelOperatorProvider)

以非同步方式從 IStorageFile 載入 ONNX 模型。

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)

參數

modelFile
IStorageFile

模型檔案的位置。

傳回

以模型檔案為基礎的 LearningModel

屬性

備註

Windows Server

若要在 Windows Server 上使用此 API,您必須搭配桌面體驗使用 Windows Server 2019。

執行緒安全

此 API 是安全線程。

適用於

LoadFromStorageFileAsync(IStorageFile)

以非同步方式從 IStorageFile 載入 ONNX 模型。

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)

參數

modelFile
IStorageFile

模型檔案的位置。

傳回

以模型檔案為基礎的 LearningModel

屬性

範例

下列範例會載入模型,並使用該模型建立模擬會話。

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;
    }
}

備註

Windows Server

若要在 Windows Server 上使用此 API,您必須搭配桌面體驗使用 Windows Server 2019。

執行緒安全

此 API 是安全線程。

適用於