public async Task LoadModelAsync(string modelName = "", int maxDetections = 20, float probabilityThreshold = 0.1f, float iouThreshold = 0.45f) { if (maxDetections > 0 && maxDetections <= 20) { this.maxDetections = maxDetections; } if (probabilityThreshold > 0 && probabilityThreshold <= 1) { this.probabilityThreshold = probabilityThreshold; } if (iouThreshold > 0 && iouThreshold <= 1) { this.iouThreshold = iouThreshold; } if (!string.IsNullOrWhiteSpace(modelName)) { ModelFilename = modelName; } ModifyText($"Loading {ModelFilename}..."); #if UNITY_WSA && !UNITY_EDITOR try { TimeRecorder = Stopwatch.StartNew(); var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Data/StreamingAssets/{ModelFilename}")); var labelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Data/StreamingAssets/labels.txt")); var labels = await FileIO.ReadLinesAsync(labelFile); Model = new ObjectDetection(labels, maxDetections, probabilityThreshold, iouThreshold); await Model.InitAsync(modelFile); TimeRecorder.Stop(); ModifyText($"Loaded {ModelFilename} in {TimeRecorder.ElapsedMilliseconds}ms"); } catch (Exception ex) { ModifyText($"Error: {ex.Message}"); Model = null; } #endif }