Я пытаюсь использовать Ml.Net Image Classification, импортируя мою модель. Как правильно ссылаться на правильный столбец в модели в модели Ml.Net.
Я попытался использовать Neutron, чтобы идентифицировать имена входов и выходов системы, чтобы ссылаться на них как на столбцы ввода и вывода.
var data = mlContext.Data.LoadFromTextFile<ImageData>(path: dataLocation, hasHeader: false);
// </SnippetLoadData>
// <SnippetMapValueToKey1>
var estimator = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName: LabelTokey, inputColumnName: "Label")
// </SnippetMapValueToKey1>
// The image transforms transform the images into the model's expected format.
// <SnippetImageTransforms>
.Append(mlContext.Transforms.LoadImages(outputColumnName: "fc8/Softmax", imageFolder: _trainImagesFolder, inputColumnName: nameof(ImageData.ImagePath)))
.Append(mlContext.Transforms.ResizeImages(outputColumnName: "fc8/Softmax", imageWidth: InceptionSettings.ImageWidth, imageHeight: InceptionSettings.ImageHeight,inputColumnName: "data"))
.Append(mlContext.Transforms.ExtractPixels(outputColumnName: "fc8/Softmax", interleavePixelColors: InceptionSettings.ChannelsLast, offsetImage: InceptionSettings.NumberOfChannels))
// </SnippetImageTransforms>
// The ScoreTensorFlowModel transform scores the TensorFlow model and allows communication
// <SnippetScoreTensorFlowModel>
.Append(mlContext.Model.LoadTensorFlowModel(inputModelLocation).
ScoreTensorFlowModel(outputColumnNames: new[] { "fc8/Softmax" }, inputColumnNames: new[] { "data" }, addBatchDimensionInput: true))
// </SnippetScoreTensorFlowModel>
// <SnippetAddTrainer>
.Append(mlContext.MulticlassClassification.Trainers.LbfgsMaximumEntropy(labelColumnName: LabelTokey, featureColumnName: "fc8/Softmax"))
// </SnippetAddTrainer>
// <SnippetMapValueToKey2>
.Append(mlContext.Transforms.Conversion.MapKeyToValue(PredictedLabelValue, "PredictedLabel"))
.AppendCacheCheckpoint(mlContext);
// </SnippetMapValueToKey2>
// Train the model
Console.WriteLine("=============== Training classification model ===============");
// Create and train the model based on the dataset that has been loaded, transformed.
// <SnippetTrainModel>
ITransformer model = estimator.Fit(data);
// </SnippetTrainModel>
// Process the training data through the model
// This is an optional step, but it's useful for debugging issues
// <SnippetTransformData>
var predictions = model.Transform(data);