public static async Task <DachshundModel> CreateDachshundModel(byte[] bits) { // Note - there is a method on LearningModelPreview which seems to // load from a stream but I got a 'not implemented' exception and // hence using a temporary file. IStorageFile file = null; var fileName = "model.bin"; try { file = await ApplicationData.Current.TemporaryFolder.GetFileAsync( fileName); } catch (FileNotFoundException) { } if (file == null) { file = await ApplicationData.Current.TemporaryFolder.CreateFileAsync( fileName); await FileIO.WriteBytesAsync(file, bits); } var model = await DachshundModel.CreateDachshundModel((StorageFile)file); return(model); }
public static async Task <DachshundModel> CreateDachshundModel(StorageFile file) { LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file); DachshundModel model = new DachshundModel(); model.learningModel = learningModel; return(model); }