public Inceptionv3() { var url = NSBundle.MainBundle.GetUrlForResource("Inceptionv3", "mlmodelc"); NSError err; Model = MLModel.Create(url, out err); }
public async Task UpdateAvailableModels() { _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, "Working | get available models..."); try { Log.Information("Get available ml models from registry."); _avalableModels.Clear(); foreach (var repository in _newConfig.Repositories) { try { var models = await MLModel.GetAvailableModelsFromRegistry(repository); foreach (var model in models) { _avalableModels.Add(new MlModelData(model.Image.Name, model.Type, model.ModelVersion, model.ApiVersion)); } } catch (Exception e) { Log.Warning(e, $"Unable to parse models from {repository}. Skipped."); } } Log.Information("Successfully get available ml models."); } catch (Exception e) { Log.Error(e, "Unable get available models."); } _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, ""); }
public ObjectDetector() { var url = NSBundle.MainBundle.GetUrlForResource("ObjectDetector", "mlmodelc"); NSError err; model = MLModel.Create(url, out err); }
public MarsHabitatPricer() { var url = NSBundle.MainBundle.GetUrlForResource("MarsHabitatPricer", "mlmodelc"); NSError err; model = MLModel.Create(url, out err); }
public TheseAreBirds() { var url = NSBundle.MainBundle.GetUrlForResource("TheseAreBirds", "mlmodelc"); NSError err; model = MLModel.Create(url, out err); }
public MobCatOrNot() { var url = NSBundle.MainBundle.GetUrlForResource("MobCatOrNot", "mlmodelc"); NSError err; model = MLModel.Create(url, out err); }
public async Task UpdateModelStatus() { _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, "Working | loading model..."); //get the last version of ml model with specific config try { Log.Information("Loading ml model."); Status = "Loading ml model..."; var config = _newConfig.MlModelConfig; // get local versions var localVersions = await MLModel.GetInstalledVersions(config); if (!localVersions.Contains(config.ModelVersion)) { throw new Exception($"There are no ml local model to init: {config.Image.Name}:{config.Image.Tag}"); } if (config.ApiVersion != API_VERSION) { throw new Exception($"Unsupported api {config.ApiVersion}. Only api v {API_VERSION} is supported."); } Repository = config.Image.Name; Version = $"{config.ModelVersion}"; Type = $"{config.Type}"; Status = $"Ready"; Log.Information("Successfully init ml model."); } catch (Exception e) { Status = $"Not ready."; Log.Error(e, "Unable to init model."); } _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, ""); }
private async void predict_predict_Click(object sender, RoutedEventArgs e) { List <float> predictions = new List <float>(); int deviceId = int.Parse(train_device.Text); string s = $"Count: {predictData.Count()}\n"; var task = Task.Run(() => { MLModel model = new MLModel($"{deviceId}.mlm"); for (int i = 0; i < predictData.Count; i++) { var prediction = model.Predict(predictData[i]); predictions.Add(prediction); s += $"{predictData[i].Timestamp.ToString("HH")}: {predictData[i].Volume:f1} -> {prediction:f1}" + $" ({((predictData[i].Volume != 0) ? 100 - predictData[i].Volume / prediction * 100:0):f2}%)\n"; } }); await Process(task); DrawChild(predictions, "Prediction"); Log(s); }
// Start is called before the first frame update void Start() { try { BoardShim.enable_dev_board_logger(); BrainFlowInputParams input_params = new BrainFlowInputParams(); int board_id = (int)BoardIds.MINDROVE_BLUETOOTH_BOARD;//= parse_args(args, input_params); board_shim = new BoardShim(board_id, input_params); board_shim.prepare_session(); board_shim.start_stream(); // use this for default options //board_shim.start_stream(450000, "file://file_stream.csv:w"); BrainFlowModelParams concentration_params = new BrainFlowModelParams((int)BrainFlowMetrics.CONCENTRATION, (int)BrainFlowClassifiers.REGRESSION); concentration = new MLModel(concentration_params); concentration.prepare(); sampling_rate = 250;//BoardShim.get_sampling_rate(board_id); eeg_channels = BoardShim.get_eeg_channels(board_id); } catch (BrainFlowException ex) { Debug.Log(ex); } }
public mymodel() { var url = NSBundle.MainBundle.GetUrlForResource("mymodel", "mlmodelc"); NSError err; model = MLModel.Create(url, out err); }
public ImageClassifier() { var url = NSBundle.MainBundle.GetUrlForResource("ImageClassifier", "mlmodelc"); NSError err; model = MLModel.Create(url, out err); }
private VNCoreMLModel LoadModel(string modelName) { var modelPath = NSBundle.MainBundle.GetUrlForResource(modelName, "mlmodelc") ?? CompileModel(modelName); if (modelPath == null) { throw new ImageClassifierException($"Model {modelName} does not exist"); } var mlModel = MLModel.Create(modelPath, out NSError err); if (err != null) { throw new NSErrorException(err); } var model = VNCoreMLModel.FromMLModel(mlModel, out err); if (err != null) { throw new NSErrorException(err); } return(model); }
static void Main(string[] args) { // use synthetic board for demo BoardShim.enable_dev_board_logger(); BrainFlowInputParams input_params = new BrainFlowInputParams(); int board_id = parse_args(args, input_params); BoardShim board_shim = new BoardShim(board_id, input_params); int sampling_rate = BoardShim.get_sampling_rate(board_shim.get_board_id()); int nfft = DataFilter.get_nearest_power_of_two(sampling_rate); int[] eeg_channels = BoardShim.get_eeg_channels(board_shim.get_board_id()); board_shim.prepare_session(); board_shim.start_stream(3600); System.Threading.Thread.Sleep(10000); board_shim.stop_stream(); double[,] data = board_shim.get_board_data(); board_shim.release_session(); Tuple <double[], double[]> bands = DataFilter.get_avg_band_powers(data, eeg_channels, sampling_rate, true); double[] feature_vector = bands.Item1.Concatenate(bands.Item2); BrainFlowModelParams model_params = new BrainFlowModelParams((int)BrainFlowMetrics.CONCENTRATION, (int)BrainFlowClassifiers.REGRESSION); MLModel concentration = new MLModel(model_params); concentration.prepare(); Console.WriteLine("Concentration: " + concentration.predict(feature_vector)); concentration.release(); }
private static VNCoreMLModel LoadModel(string modelName) { var modelPath = CompileModel(modelName); if (modelPath == null) { throw new ImageClassifierException($"Model {modelName} does not exist"); } var mlModel = MLModel.Create(modelPath, out NSError err); if (err != null) { throw new NSErrorException(err); } var model = VNCoreMLModel.FromMLModel(mlModel, out err); if (err != null) { throw new NSErrorException(err); } return(model); }
public customvision() { var url = NSBundle.MainBundle.GetUrlForResource("customvision", "mlmodelc"); NSError err; model = MLModel.Create(url, out err); }
public SqueezeNet() { var url = NSBundle.MainBundle.GetUrlForResource("SqueezeNet", "mlmodelc"); NSError err; model = MLModel.Create(url, out err); }
public PhotoDetector() { var assetPath = NSBundle.MainBundle.GetUrlForResource("FriesOrNotFries", "mlmodelc"); _mlModel = MLModel.Create(assetPath, out var _); _model = VNCoreMLModel.FromMLModel(_mlModel, out var __); }
/// <summary> /// Initializes a new instance of the <see cref="CoreMLImageModel"/> class and loads the CoreML model. /// </summary> public CoreMLImageModel(string modelName, string inputFeatureName, string outputFeatureName) { NSUrl assetPath = NSBundle.MainBundle.GetUrlForResource(modelName, "mlmodelc"); this.mlModel = MLModel.Create(assetPath, out NSError mlError); this.inputFeatureName = inputFeatureName; this.outputFeatureName = outputFeatureName; }
static JankenJudgeService() { // Load the ML model var assetPath = NSBundle.MainBundle.GetUrlForResource("jankenmodel", "mlmodelc"); var friedOrNotFriedModel = MLModel.Create(assetPath, out _); _vnmodel = VNCoreMLModel.FromMLModel(friedOrNotFriedModel, out _); }
static FriesOrNotFriesService() { // Load the ML model var assetPath = NSBundle.MainBundle.GetUrlForResource("e3e4e645c0944c6ca84f9a000e501b22", "mlmodelc"); var friedOrNotFriedModel = MLModel.Create(assetPath, out _); VModel = VNCoreMLModel.FromMLModel(friedOrNotFriedModel, out _); }
static DetectService() { // Load the ML model var assetPath = NSBundle.MainBundle .GetUrlForResource(name: "detectBalls", fileExtension: "mlmodelc"); var detectModel = MLModel.Create(url: assetPath, error: out _); VModel = VNCoreMLModel.FromMLModel(model: detectModel, error: out _); }
private async void Stop() { var config = await MLModelConfigExtension.Load(_mlConfigPath); using (var model = new MLModel(config)) { await model.Stop(); } }
public async Task PredictAll() { _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, ""); try { Status = "starting ml model..."; //load config var confDir = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "lacmus"); var configPath = Path.Join(confDir, "appConfig.json"); _appConfig = await AppConfig.Create(configPath); var config = _appConfig.MlModelConfig; using (var model = new MLModel(config)) { await model.Init(); var count = 0; var objectCount = 0; Status = "processing..."; foreach (var photoViewModel in _photos.Items) { try { photoViewModel.Annotation.Objects = await model.Predict(photoViewModel); photoViewModel.BoundBoxes = photoViewModel.GetBoundingBoxes(); if (photoViewModel.BoundBoxes.Any()) { photoViewModel.Photo.Attribute = Attribute.WithObject; photoViewModel.IsHasObject = true; } objectCount += photoViewModel.BoundBoxes.Count(); count++; PredictProgress = (double)count / _photos.Items.Count() * 100; PredictTextProgress = $"{Convert.ToInt32(PredictProgress)} %"; _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Working, $"Working | {(int)((double) count / _photos.Items.Count() * 100)} %, [{count} of {_photos.Items.Count()}]"); Console.WriteLine($"\tProgress: {(double) count / _photos.Items.Count() * 100} %"); } catch (Exception e) { Log.Error(e, $"Unable to process file {photoViewModel.Path}. Slipped."); } } Status = "stopping ml model..."; await model.Stop(); PredictTextProgress = $"predict {_photos.Count} photos."; Log.Information($"Successfully predict {_photos.Count} photos. Find {objectCount} objects."); } } catch (Exception e) { Status = "error."; Log.Error(e, "Unable to get prediction."); } _applicationStatusManager.ChangeCurrentAppStatus(Enums.Status.Ready, ""); }
void LoadMLModel() { // Load the ML model var assetPath = NSBundle.MainBundle.GetUrlForResource("44105f291f4648b2b0ad7d42d639cb20", "mlmodelc"); var mlModel = MLModel.Create(assetPath, out NSError mlErr); var vModel = VNCoreMLModel.FromMLModel(mlModel, out NSError vnErr); ClassificationRequest = new VNCoreMLRequest(vModel, HandleClassification); }
public iOSMNSSD() { var assetPath = NSBundle.MainBundle.GetUrlForResource("ssd_mobilenet_feature_extractor", "mlmodelc"); var mlModel = MLModel.Create(assetPath, out NSError mlError); if (mlError == null) { _VNMLModel = VNCoreMLModel.FromMLModel(mlModel, out mlError); } }
public IActionResult Predict(HeartData input) { var model = new MLModel(); model.Build(); var result = model.Consume(input); ViewBag.HeartPrediction = result; return(View()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MLModel.GetInstance(); // Start the Machine Learning Algorithm }
private void PrepareCoreMLModel() { var xModelPath = NSBundle.MainBundle.GetUrlForResource("xModel", "mlmodelc"); var yModelPath = NSBundle.MainBundle.GetUrlForResource("yModel", "mlmodelc"); xModel = MLModel.Create(xModelPath, out NSError xModelErrors); System.Console.WriteLine(xModel); yModel = MLModel.Create(yModelPath, out NSError yModelErrors); System.Console.WriteLine(yModel); }
VNRequest GetClassificationRequest(string resourceName) { resourceName = resourceName.Replace(".mlmodel", "").Replace(".mlmodelc", ""); var modelPath = NSBundle.MainBundle.GetUrlForResource(resourceName, ".mlmodelc"); NSError createErr, mlErr; var mlModel = MLModel.Create(modelPath, out createErr); var model = VNCoreMLModel.FromMLModel(mlModel, out mlErr); var classificationRequest = new VNCoreMLRequest(model, HandleClassifications); return(classificationRequest); }
/// <summary> /// A default constructor with default constructor value. /// </summary> public CoreMLModel() { var assetPath = NSBundle.MainBundle.GetUrlForResource(ModelName, ModelResourceExt); if (assetPath == null) { throw new FileNotFoundException(); } _mlModel = MLModel.Create(assetPath, out _); _inputFeatureName = Constants.DefaultInputFeatureName; }