MLModel LoadModel(string modelName) { NSBundle bundle = NSBundle.MainBundle; var assetPath = bundle.GetUrlForResource(modelName, "mlmodelc"); NSError err; var mdl = MLModel.Create(assetPath, out err); if (err != null) { Console.WriteLine("LoadModel Error: {0}", err); } return(mdl); }
MLModel LoadModel(string modelName) { NSBundle bundle = NSBundle.MainBundle; var assetPath = bundle.GetUrlForResource(modelName, "mlmodelc"); MLModel mdl = null; try { mdl = MLModel.FromUrl(assetPath, out var err); if (err != null) { ErrorOccurred(this, new EventArgsT <string>(err.ToString())); } } catch (ArgumentNullException ane) { Console.WriteLine("*** VGG16 model probably hasn't been downloaded, built, and added to the project's Resources. Refer to the README for instructions. Error: " + ane.Message); } return(mdl); }
/// <summary> /// Returns the file URL for the resource identified by the specified name and file extension. /// </summary> public static NSUrl URLForResource(this NSBundle source, string for_resource, string with_extension) { return(source.GetUrlForResource(for_resource, with_extension)); }