<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 10.14.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLImageClassifier/DataSource/labeledFiles(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "Create ML"
    ],
    "preciseIdentifier" : "s:8CreateML17MLImageClassifierV10DataSourceO12labeledFilesyAE10Foundation3URLV_tcAEmF"
  },
  "title" : "MLImageClassifier.DataSource.labeledFiles(at:)"
}
-->

# MLImageClassifier.DataSource.labeledFiles(at:)

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

```
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.

![Diagram showing a directory called “Training Data” containing images with names that use the label in the](images/com.apple.createml/MLImageClassifier-DataSource-labeledFiles(at:)-1@2x.png)

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)