Cannot load model using WinML

2019-08-22 10:22发布

As WinML is still fairly new and ever changing, I was hoping to know if anyone else has come across this error when trying to load a ONNX file made via the Custom Vision Service Export.

Type Error: Type (map(string,tensor(float))) of output arg (loss) of node (ZipMap) does not match expected type (seq(map(string,tensor(float))))

using Windows.AI.MachineLearning;

Windows RS5 1809 (build 17763.1) UWP SDK 17763

Testing code from this link: https://docs.microsoft.com/en-us/uwp/api/windows.ai.machinelearning

                // Load and create the model
            var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///{_modelFileName}"));
            _model = await LearningModel.LoadFromStorageFileAsync(modelFile);

Any help would be greatly appreciated.

2条回答
地球回转人心会变
2楼-- · 2019-08-22 11:04

I received info from a Microsoft associate that stated that the windows.ai.machinelearning api only supports ONNX 2. He didn't supply a date to which we can expect the custom vision service to export version 2 files.

查看更多
地球回转人心会变
3楼-- · 2019-08-22 11:18

Windows build 17763 (RS5) requires ONNX version 1.2 when Windows.AI.MachineLearning.

The Azure Custom Vision service supports this today .

Here is a post around a sample app that does this.

As a note, you need to make sure your output data type matches when you bind. In c# this looks something like this:

 public sealed class ModelOutput
        {
            public TensorString ClassLabel = TensorString.Create(new long[] { 1, 1 });
            public IList<IDictionary<string, float>> Loss = new List<IDictionary<string, float>>();
        }
查看更多
登录 后发表回答