// This file was auto-generated by ML.NET Model Builder. using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.ML; using Mask_MLML.Model; using System.IO; namespace Mask_MLML.Model { public class ConsumeModel { private static Lazy> PredictionEngine = new Lazy>(CreatePredictionEngine); // For more info on consuming ML.NET models, visit https://aka.ms/mlnet-consume // Method for consuming model in your app public static ModelOutput Predict(ModelInput input) { ModelOutput result = PredictionEngine.Value.Predict(input); return result; } public static PredictionEngine CreatePredictionEngine() { // Create new MLContext MLContext mlContext = new MLContext(); // Load model & create prediction engine string modelPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MLModel.zip"); ITransformer mlModel = mlContext.Model.Load(modelPath, out var modelInputSchema); var predEngine = mlContext.Model.CreatePredictionEngine(mlModel); return predEngine; } } }