1

I am trying to load an ONNX model using WinML, with the following code:

private async Task InitializeModelAsync()
{
    var path = @"ms-appx:///Assets/FER-Emotion-Recognition.onnx";
    var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(path));
    model = await CNTKGraphModel.CreateCNTKGraphModel(file);
}

The project compiles OK, but during run-time I am getting a System.IO.FileNotFoundException:

The system cannot find the file specified.

I double checked but the file is indeed in the right folder. What did I do wrong?

Justin XL
  • 38,763
  • 7
  • 88
  • 133

1 Answers1

3

Right click on your onnx file, go to the Properties panel and set its Build Action to Content.

Then, set the Copy to Output Directory to Copy if newer.

enter image description here

enter image description here

enter image description here

See Get started with Machine Learning

lindexi
  • 4,182
  • 3
  • 19
  • 65