In Visual studio 2022, in a .net Maui project, with the extension ML.Net, when training a model, it trains right and generate the cs files ([name].consumption.cs ; [name].training.cs and [name].mlnet) but raises the error “object reference not set to an instance of an object”
Here are the complete log before and when the problem happen :
[Before]
Updating nuget dependencies… (Microsoft.ML.ModelBuilder.Utils.Logger.Info)
2024-05-11 16:08:14.5148 INFO Starting update NuGet dependencies async. (Microsoft.ML.ModelBuilder.Utils.Logger.Info)
2024-05-11 16:08:14.5148 INFO Installing nuget package, package ID: Microsoft.ML, package Version: 3.0.1 (Microsoft.ML.ModelBuilder.Utils.Logger.Info)
2024-05-11 16:08:14.5441 INFO Installing nuget package, package ID: Microsoft.ML.Vision, package Version: 3.0.1 (Microsoft.ML.ModelBuilder.Utils.Logger.Info)
2024-05-11 16:08:14.5441 INFO Installing nuget package, package ID: SciSharp.TensorFlow.Redist, package Version: 2.3.1 (Microsoft.ML.ModelBuilder.Utils.Logger.Info)
2024-05-11 16:08:14.5681 INFO COMPLETED (Microsoft.ML.ModelBuilder.Utils.Logger.Info)
2024-05-11 16:08:15.0210 DEBUG update TrainViewModel_16.RemainingSeconds (Microsoft.ML.ModelBuilder.Utils.Logger.Debug)
2024-05-11 16:08:15.0210 DEBUG update TrainViewModel_16.RemainingTime (Microsoft.ML.ModelBuilder.Utils.Logger.Debug)
[The problem]
2024-05-11 16:08:15.0621 DEBUG La référence d’objet n’est pas définie à une instance d’un objet.
Microsoft.ML.ModelBuilder.Utils.Utilities.NeedsCompileTagsAdded(Project project) dans
//src/Microsoft.ML.ModelBuilder/Utils/Utilities.cs:ligne 408
Microsoft.ML.ModelBuilder.ViewModels.TrainViewModel.AddModelItemGroup(String stateFileNameWithoutExtension, CSharpCode pFICode) dans //src/Microsoft.ML.ModelBuilder/ViewModels/TrainViewModel.cs:ligne 1195
Microsoft.ML.ModelBuilder.ViewModels.TrainViewModel.d__98.MoveNext() dans
/_/src/Microsoft.ML.ModelBuilder/ViewModels/TrainViewModel.cs:ligne 1120 (Microsoft.ML.ModelBuilder.Utils.Logger.Debug)”
However, the training is considered as successful (see the screenshot)(https://i.sstatic.net/XII73Rbc.png)
Training on cpu and gpu gave me the same error, as well as training on other types of ML (as dataclassification, as shown in this tutorial : https://dotnet.microsoft.com/en-us/learn/ml-dotnet/get-started-tutorial/intro). However, I do not have the error if I do the same thing in a consol app.
I already tried to reinstall both Visual Studio and the extension ML.net
However, as the training was successful, visual studio still let me evaluate the model in the evaluate tab, but it does not generate any code in the consume tab.
amaury mllz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.