diff --git a/src/Microsoft.ML.Data/Model/ModelOperationsCatalog.cs b/src/Microsoft.ML.Data/Model/ModelOperationsCatalog.cs index 0443240e1d..79b39ffa3c 100644 --- a/src/Microsoft.ML.Data/Model/ModelOperationsCatalog.cs +++ b/src/Microsoft.ML.Data/Model/ModelOperationsCatalog.cs @@ -40,6 +40,17 @@ internal ModelOperationsCatalog(IHostEnvironment env) /// The loaded model. public ITransformer Load(Stream stream) => TransformerChain.LoadFrom(_env, stream); + /// + /// Load the model from a file path. + /// + /// Path to model. + /// The loaded model. + public ITransformer Load(string modelPath) + { + using (var stream = File.OpenRead(modelPath)) + return Load(stream); + } + /// /// The catalog of model explainability operations. /// diff --git a/test/Microsoft.ML.TestFramework/DataPipe/TestDataPipeBase.cs b/test/Microsoft.ML.TestFramework/DataPipe/TestDataPipeBase.cs index e89dbdf853..9dfee880dc 100644 --- a/test/Microsoft.ML.TestFramework/DataPipe/TestDataPipeBase.cs +++ b/test/Microsoft.ML.TestFramework/DataPipe/TestDataPipeBase.cs @@ -84,8 +84,7 @@ protected void TestEstimatorCore(IEstimator estimator, ML.Model.Save(transformer, fs); ITransformer loadedTransformer; - using (var fs = File.OpenRead(modelPath)) - loadedTransformer = ML.Model.Load(fs); + loadedTransformer = ML.Model.Load(modelPath); DeleteOutputPath(modelPath); // Run on train data.