Open axiom2018 opened 3 years ago
from a high level, the issue is just that the schema for ImagePath and the provided data don't match. The issue is that the ImageClassification
trainer assumes that the pixels have already been pulled out of the image into a vector, and you are just providing the image path still. Depending on the exact transformations you need to do, you will need add something like this before you call the ImageClassification
trainer:
var pipeline = mlContext.Transforms.LoadImages("ImageSource_featurized", "ImagePath")
.Append(mlContext.Transforms.ResizeImages("ImageSource_featurized", 224, 224, "ImageSource_featurized"))
.Append(mlContext.Transforms.ExtractPixels("ImageVector", "ImageSource_featurized"))
The LoadImages
call will load the image into memory as a BitMap. ResizeImages
will resize them (if needed, if you don't need to resize them you can remove this), and ExtractPixels
will pull the pixels out from the BitMap into a 3d vector.
You will then need to use the name "ImageVector" (or rename it in the ExtractPixels
call if you want) as the input for the ImageClassification
trainer.
If you are still running into issues after this can you upload your project and at least 1 sample image as a zip?
System information
Issue
What did you do? I'm learning ML.Net, and this maybe a simple question so forgive me in advance if it is but hardly any tutorials I've watched on youtube take the time to explain the code to the viewer. All I'm trying to do is follow a tutorial found here, I got stuck at 6:58 in the video when I'm supposed to call the fit function.
What happened? I get the error "'Schema mismatch for feature column 'ImagePath': expected VarVector, got String (Parameter 'inputSchema')'" Which is weird because of course the video uploader didn't get this.
What did you expect? I just expected to get the model when the fit function was called and continue the code.
Source code / logs
1) Main Code (Program.cs)
` string baseDir = Directory.GetCurrentDirectory(); string realDir = Path.GetFullPath(Path.Combine(baseDir, @"......\")); string imgFolderDir = realDir + "images\";
2) ImageData (Input)
` public class ImageData { [LoadColumn(0)] public string ImagePath;
3) ImagePrediction (Output)
` public class ImagePrediction { // Scores we get from the model. How sure it is on a guess. [ColumnName("Score")] public float[] Score;
Also, here's a link to the guy in the videos github so you can compare and contrast my code to his. What exactly am I doing wrong?