public async Task LoadModelAsync(string modelName = "", float accuracy = 0.5f)
    {
        if (accuracy > 0)
        {
            this.accuracy = accuracy;
        }

        if (!String.IsNullOrEmpty(modelName))
        {
            ModelFilename = modelName;
        }
        ModifyText($"Loading {ModelFilename}... Patience");

#if UNITY_WSA && !UNITY_EDITOR
        try
        {
            TimeRecorder = Stopwatch.StartNew();


            var modelFile = await StorageFile.GetFileFromApplicationUriAsync(
                new Uri($"ms-appx:///Data/StreamingAssets/{ModelFilename}"));

            Model = await ONNXModel.CreateOnnxModel(modelFile);

            TimeRecorder.Stop();
            ModifyText($"Loaded {ModelFilename}: Elapsed time: {TimeRecorder.ElapsedMilliseconds} ms");
        }
        catch (Exception ex)
        {
            ModifyText($"error: {ex.Message}");
            Model = null;
        }
#endif
    }
        public async Task LoadModelAsync(string filename = null)
        {
            if (!string.IsNullOrEmpty(filename))
            {
                ModelFilename = filename;
            }

            try
            {
                var modelFile = await StorageFile.GetFileFromApplicationUriAsync(
                    new Uri($"ms-appx:///Data/StreamingAssets/{ModelFilename}"));

                Model = await ONNXModel.CreateOnnxModel(modelFile);
            }
            catch (Exception ex)
            {
                InvokeNullsafe(new RecognitionResult(ResultType.Failed, ex.Message, "", -1));
                Model = null;
            }
        }
Esempio n. 3
0
    public async Task LoadModelAsync()
    {
        ModifyText($"Loading {ModelFilename}... Patience");

        try
        {
            TimeRecorder = Stopwatch.StartNew();

            var modelFile = await StorageFile.GetFileFromApplicationUriAsync(
                new Uri($"ms-appx:///Data/StreamingAssets/{ModelFilename}"));

            Model = await ONNXModel.CreateOnnxModel(modelFile);

            TimeRecorder.Stop();
            ModifyText($"Loaded {ModelFilename}: Elapsed time: {TimeRecorder.ElapsedMilliseconds} ms");
        }
        catch (Exception ex)
        {
            ModifyText($"error: {ex.Message}");
            Model = null;
        }
    }