Skip to content

[Image Classification DNN Transfer Learning] - Support training and scoring with in-memory images #4153

@CESARDELATORRE

Description

@CESARDELATORRE

The new DNN-Transfer-Learning is very nicely simplified (and it'll be even more simplified), however, the way it is now doesn't support to train and score with in-memory images, therefore, if you train with image filepaths, the model for scoring also requires image paths...

That's limiting in-memory images scenarios that we really need to support.

For instance, in the code below, the API ImageClassification() is expecting image filepaths, only.

    public class ImageData
    {
        [LoadColumn(0)]
        public string ImagePath;

        [LoadColumn(1)]
        public string Label;
    }

//...
var pipeline = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName: "LabelAsKey", 
                                                                inputColumnName: "Label",
                                                                keyOrdinality: ValueToKeyMappingEstimator.KeyOrdinality.ByValue)
            .Append(mlContext.Model.ImageClassification("ImagePath", "LabelAsKey",
                            arch: ImageClassificationEstimator.Architecture.ResnetV2101,
                            epoch: 100,     //An epoch is one learning cycle where the learner sees the whole training data set.
                            batchSize: 100, // batchSize sets the number of images to feed the model at a time. It needs to divide the training set evenly or the remaining part won't be used for training. Use 10 for hundreds of images, 100 for thousands of images                             
                            metricsCallback: (metrics) => Console.WriteLine(metrics),
                            reuseTrainSetBottleneckCachedValues: false,
                            reuseValidationSetBottleneckCachedValues: false,
                            validationSet: transformedValidationDataView));

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions