Contents

MLImageClassifier.DataSource.labeledFiles(at:)

An image classifier data source that uses file names to label images.

Declaration

case labeledFiles(at: URL)

Discussion

Use this case to create a data source based on a files on disk that contain your training images. The associated value is a URL that represents a directory containing files with names based on each image’s associated label. The image’s label is taken as the part of the file name up to the first period.

For example, you can initialize a data source with a file URL that indicates a directory called Training Data that contains the files buffalo.1.jpg, buffalo.2.jpg, cheetah.1.jpg, and cheetah.2.jpg. The first two images receive the label buffalo, while the second two images receive the label cheetah. The part of the name after the first period can be any arbitrary string.

[Image]

If you want to create a data source with labels based on how you sort your images into directories, use MLImageClassifier.DataSource.labeledDirectories(at:) instead.

See Also

Creating a data source