Example #1
0
        private async Task LoadModelAsync()
        {
            StorageFile modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/{_ourOnnxFileName}"));

            _model = new CustomVision.ObjectDetection(new string[] { "AceOfHearts" });
            await _model.Init(modelFile);
        }
Example #2
0
        // Doing this to test loading model from bytes which I have in Unity
        // It randomly freezes the application. Wish I understood streams.
        // I'll have to resort to the "write model file to disk then read model file from disk" idiocy.
        private async Task LoadModelFromBytes()
        {
            StorageFile modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/{_ourOnnxFileName}"));

            byte[] myBytes = await GetBytesAsync(modelFile);

            IRandomAccessStreamReference streamReference = await ConvertToRandomAccessStream(myBytes);

            _model = new CustomVision.ObjectDetection(new string[] { "AceOfHearts" });
            _model.Init(streamReference);
        }