Ejemplo n.º 1
0
        public static async Task <truckModel> CreateFromStreamAsync(IRandomAccessStreamReference stream)
        {
            truckModel learningModel = new truckModel();

            learningModel.model = await LearningModel.LoadFromStreamAsync(stream);

            learningModel.session = new LearningModelSession(learningModel.model);
            learningModel.binding = new LearningModelBinding(learningModel.session);
            return(learningModel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load and create the model from the .onnx file
        /// </summary>
        /// <returns></returns>
        private async Task LoadModelAsync()
        {
            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/{modelFileName}"));

            // Create the model from the file
            // IMPORTANT: Change `Model.CreateModel` to match the class and methods in the
            //   .cs file generated from the ONNX model
            string        fname = $@"Assets\{modelFileName}";
            StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
            StorageFile   modelFile          = await InstallationFolder.GetFileAsync(fname);

            if (File.Exists(file.Path))
            {
                //"mask", "nomask"
                model = new ObjectDetection(new string[] { "Container", "Truck Container" });//await ONNXModel.CreateONNXModel(file);
                await model.Init(modelFile);

                model1 = await truckModel.CreateFromStreamAsync(modelFile);
            }
        }