1

I am new to Machine Learning.

I use ML.Net Image Classification on Windows system using InceptionV3 and let say i already have a trained model with the 100 cats and 100 dogs photos and saved trained model as ZIP file.

Now in future i found few more 10 cats and i would like to add those to the existing saved trained ZIP model file instead of retraining all the old and new cats and dogs, how would i achieve this?

Any help would be appreciated.

Here is my code which creates a Model and saves it on the last line... but now i would like to add newly found cats to the existing saved model without retraining model with the old cats & dogs photos. please help.

MLContext mlContext = new MLContext(seed: 1);

IEnumerable<ImageData> images = LoadImagesFromDirectory(folder: fullImagesetFolderPath, useFolderNameasLabel: true);

IDataView fullImagesDataset = mlContext.Data.LoadFromEnumerable(images);
IDataView shuffledFullImagesDataset = mlContext.Data.ShuffleRows(fullImagesDataset);

var pipeline = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName: "LabelAsKey",
                                                                        inputColumnName: "Label",
                                                                        keyOrdinality: ValueToKeyMappingEstimator.KeyOrdinality.ByValue)
                    .Append(mlContext.Model.ImageClassification("ImagePath", "LabelAsKey",
                           arch: ImageClassificationEstimator.Architecture.InceptionV3,
                           epoch: 20,
                               batchSize: 5));

  ITransformer trainedModel = pipeline.Fit(trainDataView);

  mlContext.Model.Save(trainedModel, trainDataView.Schema, outputMlNetModelFilePath);
Chintan Patel
  • 329
  • 2
  • 3
  • 5
  • I don't think the possibility exists to retrain without the older samples. unless if you somehow store the state of the training somewhere, and pick up later... I'm curious about this as well. – Glenn van Acker Oct 15 '19 at 11:49
  • I don't think you can. There is no way of adding data to your trained model. There are cases where you can train a new model partly based on the older model (https://stackoverflow.com/questions/53318863/ml-net-add-new-data-to-exist-generated-model, https://stackoverflow.com/questions/52470794/ml-net-retrain-existing-model-rather-than-training-new-model?rq=1), but I don't think it's applicable to ImageClassification. – Wouter Bouwman Oct 15 '19 at 12:33

0 Answers0