dotnet / dotnet/machinelearning-modelbuilder
'object reference not set to an instance of an object' when training a image classification model
- Dominant language
- Dockerfile
- Stars
- 285
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
**System Information (please complete the following information):**
- Model Builder Version (available in Manage Extensions dialog): 17.18.2.2415501
- Visual Studio Version : community 2022 17.9.6, in a .net Maui project
**Describe the bug**
- On which step of the process did you run into an issue: when training the model, it trains right and generate the cs files but raise the error "object reference not set to an instance of an object"
- Clear description of the problem: here are the log before and when the problem happen :
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)
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)

training on cpu and gpu gave me the same error.
**To Reproduce**
Steps to reproduce the behavior:
1. create a .Net maui project
2. Add the ML.Net extension
3. Select the 'image classification' model, with cpu or gpu training, then select random data (2 folders for me, with 467 images total) and start training. For me the error came at the end of the training.
**Expected behavior**
A clear and concise description of what you expected to happen.
I expected it to end the training and generate model files
**Screenshots**
If applicable, add screenshots to help explain your problem.
Evaluate tab after training (with error) :

Consume tab after training (with error) :

Also, I reinstalled Visual Studio and the ML.net extension twice and I still have the same error. My NuGet packages are up to date. However, I do not have this error on other type of project as c# console app (following this tutorial to set it up https://dotnet.microsoft.com/en-us/learn/ml-dotnet/get-started-tutorial/intro)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.