dotnet / dotnet/machinelearning-modelbuilder
'object reference not set to an instance of an object' when training a image classification model
- Langage dominant
- Dockerfile
- Étoiles
- 285
- Forks
- 66
- Métriques de merge des PR
- Aucune PR mergée en 30 j
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)
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par reproduire l’entraînement de classification d’images dans un projet .NET MAUI, puis examinez Utilities.cs à la ligne 408 et TrainViewModel.cs aux lignes 1120 et 1195 à l’aide de la stack trace signalée. Confirmez que l’entraînement se termine sans l’erreur de référence null et que le modèle et les fichiers C# générés sont utilisables.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp
- Domaine
- machine-learning
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100