飞扬的Blog
主页
登录
ML.NET ASP.NET CORE 依赖注入
"date"
:
"2023-02-21 23:57:17"
"classfiy"
:
"asp.net core"
"author"
:
"飞扬"
"viewTimes"
:
376
返回
``` using Microsoft.Extensions.ML; services.AddPredictionEnginePool<ModelInput, ModelOutput>() .FromFile(GetAbsolutePath("file.zip")); string GetAbsolutePath(string relativePath) { var _dataRoot = new FileInfo(typeof(Program).Assembly.Location); var assemblyFolderPath = _dataRoot.Directory.FullName; var fullPath = Path.Combine(assemblyFolderPath, relativePath); return fullPath; } //controller private readonly PredictionEnginePool<ModelInput, ModelOutput> _predictionEnginePool; ```