public static async Task <OnnxModel> CreateOnnxModel(StorageFile file) { LearningModelPreview learningModel = null; try { learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file); } catch (Exception e) { var exceptionStr = e.ToString(); System.Console.WriteLine(exceptionStr); throw e; } OnnxModel model = new OnnxModel(); learningModel.InferencingOptions.PreferredDeviceKind = LearningModelDeviceKindPreview.LearningDeviceAny; learningModel.InferencingOptions.ReclaimMemoryAfterEvaluation = true; model.learningModel = learningModel; return(model); }
public static async Task <OnnxModel> CreateOnnxModel() { var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets//ModelsAI//model.onnx")); return(await OnnxModel.CreateOnnxModel(modelFile)); }
public async Task Init() { onnxmodel = await OnnxModel.CreateOnnxModel(); }