コード例 #1
0
    public async void InitializeModelAsync()
    {
        //若模型已加载,则可略过此步
        if (this.model != null)
        {
            return;
        }

        //ms-appx是指当前正运行应用的程序包。应该是Assets/StreamingAssets下的文件部署至Hololens后会在Data文件夹中
        StorageFile tinyYoloModelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Data/StreamingAssets/TinyYOLO.onnx"));

        this.model = await LearningModelPreview.LoadModelFromStorageFileAsync(tinyYoloModelFile);

        //评估后回收内存
        this.model.InferencingOptions.ReclaimMemoryAfterEvaluation = true;
        this.model.InferencingOptions.PreferredDeviceKind          =
            shouldUseGpu ? LearningModelDeviceKindPreview.LearningDeviceGpu : LearningModelDeviceKindPreview.LearningDeviceCpu;


        //模型的输入描述是Image,输出是Tensor
        var inputFeatures  = this.model.Description.InputFeatures.ToArray();
        var outputFeatures = this.model.Description.OutputFeatures.ToArray();

        this.inputImageDescription   = inputFeatures.FirstOrDefault(feature => feature.ModelFeatureKind == LearningModelFeatureKindPreview.Image) as ImageVariableDescriptorPreview;
        this.outputTensorDescription = outputFeatures.FirstOrDefault(feature => feature.ModelFeatureKind == LearningModelFeatureKindPreview.Tensor) as TensorVariableDescriptorPreview;

        if (this.model != null)
        {
            DisplayText("Tiny YOLO Model Loaded. Please Walk Around to Scan the Environment... ");
            Debug.Log("Initialize Model Async Succeed! ");
        }
    }
コード例 #2
0
        private async Task LoadModelAsync()
        {
            if (this.model != null)
            {
                return;
            }

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => StatusBlock.Text = $"Loading { MODEL_FILENAME } ... patience ");

            try
            {
                // Load Model
                var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/{ MODEL_FILENAME }"));

                this.model = await LearningModelPreview.LoadModelFromStorageFileAsync(modelFile);

                // Retrieve model input and output variable descriptions (we already know the model takes an image in and outputs a tensor)
                var inputFeatures  = this.model.Description.InputFeatures.ToList();
                var outputFeatures = this.model.Description.OutputFeatures.ToList();

                this.inputImageDescription =
                    inputFeatures.FirstOrDefault(feature => feature.ModelFeatureKind == LearningModelFeatureKindPreview.Image)
                    as ImageVariableDescriptorPreview;

                this.outputTensorDescription =
                    outputFeatures.FirstOrDefault(feature => feature.ModelFeatureKind == LearningModelFeatureKindPreview.Tensor)
                    as TensorVariableDescriptorPreview;
            }
            catch (Exception ex)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => StatusBlock.Text = $"error: {ex.Message}");

                model = null;
            }
        }
コード例 #3
0
        public void SetProperties(IPropertySet configuration)
        {
            this.configuration = configuration;

            var modelFile = StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///segm_video_effect_uwp/Assets/{_kModelFileName}")).GetAwaiter().GetResult();

            Debug.WriteLine(modelFile);

            _learningModel = LearningModelPreview.LoadModelFromStorageFileAsync(modelFile).GetAwaiter().GetResult();

            InferencingOptionsPreview options = _learningModel.InferencingOptions;

            options.PreferredDeviceKind = LearningModelDeviceKindPreview.LearningDeviceGpu;
            //options.IsTracingEnabled = true;

            _learningModel.InferencingOptions = options;

            fpsTimer           = new Timer(1000);
            fpsTimer.Elapsed  += this.OnTimedEvent;
            fpsTimer.AutoReset = true;
            fpsTimer.Start();

            fpsLabelOffset = new Vector2(10, 10);
            fpsLabelColor  = Color.FromArgb(255, 255, 0, 0);
        }
コード例 #4
0
        public async Task LoadModelAsync()
        {
            try
            {
                // Load Model
                var modelFile = await StorageFile.GetFileFromApplicationUriAsync(
                    new Uri($"ms-appx:///Assets/FERPlus.onnx"));

                model = await LearningModelPreview.LoadModelFromStorageFileAsync(modelFile);

                // Retrieve model input and output variable descriptions (we already know
                // the model takes an image in and outputs a tensor)
                var inputFeatures  = model.Description.InputFeatures.ToList();
                var outputFeatures = model.Description.OutputFeatures.ToList();

                inputImageDescription =
                    inputFeatures.FirstOrDefault(
                        feature => feature.ModelFeatureKind == LearningModelFeatureKindPreview.Image)
                    as ImageVariableDescriptorPreview;

                outputTensorDescription =
                    outputFeatures.FirstOrDefault(
                        feature => feature.ModelFeatureKind == LearningModelFeatureKindPreview.Tensor)
                    as TensorVariableDescriptorPreview;
            }
            catch (Exception)
            {
                model = null;
                throw;
            }
        }
コード例 #5
0
        public static async Task <15fb3d9ea39f4068ad44a49de20faedcModel> Create15fb3d9ea39f4068ad44a49de20faedcModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            15fb3d9ea39f4068ad44a49de20faedcModel model = new 15fb3d9ea39f4068ad44a49de20faedcModel ();
            model.learningModel = learningModel;
            return(model);
        }
コード例 #6
0
        public static async Task <TinyYoloModel> CreateTinyYoloModel(StorageFile file)
        {
            var learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            return(new TinyYoloModel {
                learningModel = learningModel
            });
        }
コード例 #7
0
        internal static async Task <FERModel> CreateFERModel(StorageFile file)
        {
            var learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            return(new FERModel {
                learningModel = learningModel
            });
        }
コード例 #8
0
        /// <summary>
        /// Initialize the ML model with isGpu defined
        /// </summary>
        private async Task InitializeMLModel(bool isGpu)
        {
            this.LearningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(this.ModelFile);

            this.LearningModel.InferencingOptions.ReclaimMemoryAfterEvaluation = true;
            this.LearningModel.InferencingOptions.PreferredDeviceKind          = isGpu == true ?
                                                                                 LearningModelDeviceKindPreview.LearningDeviceGpu : LearningModelDeviceKindPreview.LearningDeviceCpu;
        }
コード例 #9
0
        public static async Task <C2302845_x002D_023d_x002D_4c61_x002D_9b48_x002D_25d860a0c350_c6ad3001_x002D_dc81_x002D_45fd_x002D_a943_x002D_e7afa90c07f5Model> CreateC2302845_x002D_023d_x002D_4c61_x002D_9b48_x002D_25d860a0c350_c6ad3001_x002D_dc81_x002D_45fd_x002D_a943_x002D_e7afa90c07f5Model(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            C2302845_x002D_023d_x002D_4c61_x002D_9b48_x002D_25d860a0c350_c6ad3001_x002D_dc81_x002D_45fd_x002D_a943_x002D_e7afa90c07f5Model model = new C2302845_x002D_023d_x002D_4c61_x002D_9b48_x002D_25d860a0c350_c6ad3001_x002D_dc81_x002D_45fd_x002D_a943_x002D_e7afa90c07f5Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #10
0
        public static async Task <TinyYoloV1_0Model> CreateTinyYoloV1_0Model(StorageFile file)
        {
            var learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            var model = new TinyYoloV1_0Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #11
0
        public static async Task <ResNet50Model> CreateResNet50Model(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            ResNet50Model model = new ResNet50Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #12
0
        public async Task InitializeAsync(ModelType modelType, params string[] parameters)
        {
            var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(parameters[0]));

            var learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            tags = parameters.Skip(1).ToArray();
            this.learningModel = learningModel;
        }
コード例 #13
0
        public static async Task <Ee7165d4_x002D_31e3_x002D_468e_x002D_ba0c_x002D_565f0b33d377_1bc49a81_x002D_827d_x002D_48b3_x002D_84bf_x002D_3a9555b4c54eModel> CreateEe7165d4_x002D_31e3_x002D_468e_x002D_ba0c_x002D_565f0b33d377_1bc49a81_x002D_827d_x002D_48b3_x002D_84bf_x002D_3a9555b4c54eModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            Ee7165d4_x002D_31e3_x002D_468e_x002D_ba0c_x002D_565f0b33d377_1bc49a81_x002D_827d_x002D_48b3_x002D_84bf_x002D_3a9555b4c54eModel model = new Ee7165d4_x002D_31e3_x002D_468e_x002D_ba0c_x002D_565f0b33d377_1bc49a81_x002D_827d_x002D_48b3_x002D_84bf_x002D_3a9555b4c54eModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #14
0
        public static async Task <CatOrDogModel> CreateCatOrDogModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            CatOrDogModel model = new CatOrDogModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #15
0
        public static async Task <_x0034_7c46b62_x002D_55d4_x002D_418f_x002D_9667_x002D_bca58c105516_df5a0f61_x002D_d714_x002D_4789_x002D_8077_x002D_27f227995765Model> Create_x0034_7c46b62_x002D_55d4_x002D_418f_x002D_9667_x002D_bca58c105516_df5a0f61_x002D_d714_x002D_4789_x002D_8077_x002D_27f227995765Model(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            _x0034_7c46b62_x002D_55d4_x002D_418f_x002D_9667_x002D_bca58c105516_df5a0f61_x002D_d714_x002D_4789_x002D_8077_x002D_27f227995765Model model = new _x0034_7c46b62_x002D_55d4_x002D_418f_x002D_9667_x002D_bca58c105516_df5a0f61_x002D_d714_x002D_4789_x002D_8077_x002D_27f227995765Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #16
0
        public static async Task <ViscoreitanoModel> CreateViscoreitanoModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            ViscoreitanoModel model = new ViscoreitanoModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #17
0
        public static async Task <BirdRecognizerModel> CreateBirdRecognizerModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            BirdRecognizerModel model = new BirdRecognizerModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #18
0
        public static async Task <Model> CreateModel(StorageFile file, IEnumerable <string> labels)
        {
            var learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            return(new Model(labels)
            {
                _learningModel = learningModel
            });
        }
コード例 #19
0
        public static async Task <_x0035_3979b10_x002D_4cb6_x002D_417f_x002D_9f57_x002D_a85d70709fbc_44105f29_x002D_1f46_x002D_48b2_x002D_b0ad_x002D_7d42d639cb20Model> Create_x0035_3979b10_x002D_4cb6_x002D_417f_x002D_9f57_x002D_a85d70709fbc_44105f29_x002D_1f46_x002D_48b2_x002D_b0ad_x002D_7d42d639cb20Model(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            _x0035_3979b10_x002D_4cb6_x002D_417f_x002D_9f57_x002D_a85d70709fbc_44105f29_x002D_1f46_x002D_48b2_x002D_b0ad_x002D_7d42d639cb20Model model = new _x0035_3979b10_x002D_4cb6_x002D_417f_x002D_9f57_x002D_a85d70709fbc_44105f29_x002D_1f46_x002D_48b2_x002D_b0ad_x002D_7d42d639cb20Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #20
0
        public static async Task <_x0039_3deb65e_x002D_dfa1_x002D_49a3_x002D_8a7c_x002D_b802a3a909e1_28f9b6ec_x002D_eae5_x002D_49e6_x002D_8da7_x002D_2b70beb4c498Model> Create_x0039_3deb65e_x002D_dfa1_x002D_49a3_x002D_8a7c_x002D_b802a3a909e1_28f9b6ec_x002D_eae5_x002D_49e6_x002D_8da7_x002D_2b70beb4c498Model(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            _x0039_3deb65e_x002D_dfa1_x002D_49a3_x002D_8a7c_x002D_b802a3a909e1_28f9b6ec_x002D_eae5_x002D_49e6_x002D_8da7_x002D_2b70beb4c498Model model = new _x0039_3deb65e_x002D_dfa1_x002D_49a3_x002D_8a7c_x002D_b802a3a909e1_28f9b6ec_x002D_eae5_x002D_49e6_x002D_8da7_x002D_2b70beb4c498Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #21
0
        public static async Task <Af4dec16_x002D_0900_x002D_4f35_x002D_8d03_x002D_28743433843e_cb36632a_x002D_770d_x002D_4ef8_x002D_a996_x002D_d3b067ff0e11Model> CreateAf4dec16_x002D_0900_x002D_4f35_x002D_8d03_x002D_28743433843e_cb36632a_x002D_770d_x002D_4ef8_x002D_a996_x002D_d3b067ff0e11Model(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            Af4dec16_x002D_0900_x002D_4f35_x002D_8d03_x002D_28743433843e_cb36632a_x002D_770d_x002D_4ef8_x002D_a996_x002D_d3b067ff0e11Model model = new Af4dec16_x002D_0900_x002D_4f35_x002D_8d03_x002D_28743433843e_cb36632a_x002D_770d_x002D_4ef8_x002D_a996_x002D_d3b067ff0e11Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #22
0
        public static async Task <E6c82f6e_x002D_c60f_x002D_422a_x002D_97b6_x002D_e0406cba82da_6ed0259c_x002D_001e_x002D_4895_x002D_be7a_x002D_4a930321a307Model> CreateE6c82f6e_x002D_c60f_x002D_422a_x002D_97b6_x002D_e0406cba82da_6ed0259c_x002D_001e_x002D_4895_x002D_be7a_x002D_4a930321a307Model(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            E6c82f6e_x002D_c60f_x002D_422a_x002D_97b6_x002D_e0406cba82da_6ed0259c_x002D_001e_x002D_4895_x002D_be7a_x002D_4a930321a307Model model = new E6c82f6e_x002D_c60f_x002D_422a_x002D_97b6_x002D_e0406cba82da_6ed0259c_x002D_001e_x002D_4895_x002D_be7a_x002D_4a930321a307Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #23
0
        /// <summary>
        /// Create model, returns instance of BearClassification model from model path
        /// </summary>
        /// <param name="file">The .onnx file location</param>
        /// <returns></returns>
        public static async Task <BearClassificationModel> CreateBearClassificationModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            BearClassificationModel model = new BearClassificationModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #24
0
ファイル: nic.cs プロジェクト: miriamht/CognitiveRocket
        public static async Task <_x0035_f11ca47_x002D_2841_x002D_4ece_x002D_af83_x002D_e7bc2b5e8603_fe5629e0_x002D_49e2_x002D_4e9c_x002D_be74_x002D_076aa419dcddModel> Create_x0035_f11ca47_x002D_2841_x002D_4ece_x002D_af83_x002D_e7bc2b5e8603_fe5629e0_x002D_49e2_x002D_4e9c_x002D_be74_x002D_076aa419dcddModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            _x0035_f11ca47_x002D_2841_x002D_4ece_x002D_af83_x002D_e7bc2b5e8603_fe5629e0_x002D_49e2_x002D_4e9c_x002D_be74_x002D_076aa419dcddModel model = new _x0035_f11ca47_x002D_2841_x002D_4ece_x002D_af83_x002D_e7bc2b5e8603_fe5629e0_x002D_49e2_x002D_4e9c_x002D_be74_x002D_076aa419dcddModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #25
0
        public static async Task <TinyYOLOModelModel> CreateTinyYOLOModelModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            TinyYOLOModelModel model = new TinyYOLOModelModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #26
0
        public static async Task <InkshapesModel> CreateInkshapesModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            InkshapesModel model = new InkshapesModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #27
0
        public static async Task <GoogLeNetPlacesModelModel> CreateGoogLeNetPlacesModelModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            GoogLeNetPlacesModelModel model = new GoogLeNetPlacesModelModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #28
0
        public static async Task <_x0036_fba5602_x002D_2416_x002D_4582_x002D_8f3b_x002D_931bc0eadc24_c97c9b55_x002D_21f5_x002D_48b8_x002D_9a25_x002D_83f235a0d8d7Model> Create_x0036_fba5602_x002D_2416_x002D_4582_x002D_8f3b_x002D_931bc0eadc24_c97c9b55_x002D_21f5_x002D_48b8_x002D_9a25_x002D_83f235a0d8d7Model(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            _x0036_fba5602_x002D_2416_x002D_4582_x002D_8f3b_x002D_931bc0eadc24_c97c9b55_x002D_21f5_x002D_48b8_x002D_9a25_x002D_83f235a0d8d7Model model = new _x0036_fba5602_x002D_2416_x002D_4582_x002D_8f3b_x002D_931bc0eadc24_c97c9b55_x002D_21f5_x002D_48b8_x002D_9a25_x002D_83f235a0d8d7Model();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #29
0
        public static async Task <MobilenetModel> CreateMobilenetModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            MobilenetModel model = new MobilenetModel();

            model.learningModel = learningModel;
            return(model);
        }
コード例 #30
0
        public static async Task <DacshundModel> CreateDaschundModel(StorageFile file)
        {
            LearningModelPreview learningModel = await LearningModelPreview.LoadModelFromStorageFileAsync(file);

            DacshundModel model = new DacshundModel();

            model.learningModel = learningModel;
            return(model);
        }