Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            var pathModel = ConsumeModel.GetAbsolutePath("MLModel.zip");

            services.AddPredictionEnginePool <ModelInput, ModelOutput>().FromFile(pathModel);
        }
        public async Task <IActionResult> ClasificarImagen(ImageClassification imageClassification)
        {
            string pathPrediction = @"..\..\..\..\..\data\Predict\";
            string pathImgPredict = Path.Combine(pathPrediction, imageClassification.ImgFile.FileName);

            pathImgPredict = ConsumeModel.GetAbsolutePath(pathImgPredict);

            using (var stream = System.IO.File.Create(pathImgPredict))
            {
                await imageClassification.ImgFile.CopyToAsync(stream);
            }

            imageClassification.ImageData = new ModelInput()
            {
                ImageSource = pathImgPredict,
                Label       = "Desconocido",
            };
            imageClassification.ImagePrediction = new ModelOutput();


            imageClassification.ImagePrediction = QueTipoDeProductoEs(imageClassification.ImageData);

            return(View(imageClassification));
        }