MLImageClassifier.DataSource
A data source for an image classifier.
Declaration
enum DataSourceMentioned in
Overview
Use a data source to provide training or testing data to an image classifier.
To train a model programmatically with an MLImageClassifier instance, initialize a data source with the URL of the directory that contains the data. Use either MLImageClassifier.DataSource.labeledDirectories(at:) or MLImageClassifier.DataSource.labeledFiles(at:) to do this, depending on whether your images are grouped by directory or by file name. See the respective creation methods for details about how to arrange your image files in each case.
When you train a model using MLImageClassifierBuilder, you don’t initialize a data source directly. Instead, you drag the directory containing your data from a Finder window into the live view. The builder automatically chooses the correct kind of data source based on how your images are arranged inside that directory, looking for either labeled directories or labeled files.