Ejemplo n.º 1
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            _tensorFlowModelFilePath = GetAbsolutePath(Configuration["MLModel:TensorFlowModelFilePath"]);

            /////////////////////////////////////////////////////////////////
            //Configure the ML.NET model for the pre-trained TensorFlow model.
            var tensorFlowModelConfigurator = new TensorFlowModelConfigurator(_tensorFlowModelFilePath);

            _mlnetModel = tensorFlowModelConfigurator.Model;
        }
Ejemplo n.º 2
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            _tensorFlowModelFilePath = GetAbsolutePath(Configuration["MLModel:TensorFlowModelFilePath"]);
            _mlnetModelFilePath      = GetAbsolutePath(Configuration["MLModel:MLNETModelFilePath"]);

            /////////////////////////////////////////////////////////////////
            //Configure the ML.NET model for the pre-trained TensorFlow model
            TensorFlowModelConfigurator tensorFlowModelConfigurator = new TensorFlowModelConfigurator(_tensorFlowModelFilePath);

            // Save the ML.NET model .zip file based on the TensorFlow model and related configuration
            tensorFlowModelConfigurator.SaveMLNetModel(_mlnetModelFilePath);
        }
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            _tensorFlowModelFilePath = GetAbsolutePath(Configuration["MLModel:TensorFlowModelFilePath"]);
            _mlnetModelFilePath      = GetAbsolutePath(Configuration["MLModel:MLNETModelFilePath"]);
            _tempImagesFolderPath    = GetAbsolutePath(Configuration["MLModel:TempImagesFolderPath"]);

            /////////////////////////////////////////////////////////////////
            //Configure the ML.NET model for the pre-trained TensorFlow model
            TensorFlowModelConfigurator tensorFlowModelConfigurator = new TensorFlowModelConfigurator(_tempImagesFolderPath, _tensorFlowModelFilePath);

            tensorFlowModelConfigurator.SaveMLNetModel(_mlnetModelFilePath);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            // Generate and save the ML.NET model .zip file based on the TensorFlow model and related configuration
            TensorFlowModelConfigurator tensorFlowModelConfigurator = new TensorFlowModelConfigurator(_tempImagesFolderPath, _tensorFlowModelFilePath);

            /////////////////////////////////////////////////////////////////////////////
            // Register the PredictionEnginePool as a service in the IoC container for DI
            //
            services.AddPredictionEnginePool <ImageInputData, ImageLabelPredictions>()
            .FromFile(_mlnetModelFilePath);
        }