<!--
{
  "availability" : [
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLObjectDetector",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML"
    ],
    "preciseIdentifier" : "s:8CreateML16MLObjectDetectorV"
  },
  "title" : "MLObjectDetector"
}
-->

# MLObjectDetector

A model you train to classify one or more objects within an image.

```
struct MLObjectDetector
```

## Overview

Use an [`MLObjectDetector`](/documentation/CreateML/MLObjectDetector) task to train a machine learning model that can identify items, or *objects*, within an
image. For example, you can train an object detector to recognize breakfast items on a table, such as bananas,
croissants, and beverages.

You create an object detector training it with a combination of images and annotations for each object within an
image. Then save it as a Core ML model and use it in your app to recognize similar items.

## Topics

### Creating a data source

[Building an object detector data source](/documentation/CreateML/building-an-object-detector-data-source)

Arrange your training data for an object detector in one of several different
structured ways.

### Training an object detector asynchronously

[`train(trainingData:annotationType:parameters:sessionParameters:)`](/documentation/CreateML/MLObjectDetector/train(trainingData:annotationType:parameters:sessionParameters:))

Begins an asynchronous object-detector training session.

[`makeTrainingSession(trainingData:annotationType:parameters:sessionParameters:)`](/documentation/CreateML/MLObjectDetector/makeTrainingSession(trainingData:annotationType:parameters:sessionParameters:))

Creates an asynchronous object-detector training session.

[`resume(_:)`](/documentation/CreateML/MLObjectDetector/resume(_:))

Begins or continues an asynchronous object-detector training session.

[`restoreTrainingSession(sessionParameters:)`](/documentation/CreateML/MLObjectDetector/restoreTrainingSession(sessionParameters:))

Creates an asynchronous training session for an object detector by restoring an existing training session’s
state from its parameters.

### Creating an object detector from a checkpoint

[`init(checkpoint:)`](/documentation/CreateML/MLObjectDetector/init(checkpoint:))

Creates an object detector from a training session checkpoint.

### Training an object detector synchronously

[`init(trainingData:parameters:annotationType:)`](/documentation/CreateML/MLObjectDetector/init(trainingData:parameters:annotationType:))

Creates an object detector with a data source.

[`init(trainingData:imageColumn:annotationColumn:annotationType:parameters:)`](/documentation/CreateML/MLObjectDetector/init(trainingData:imageColumn:annotationColumn:annotationType:parameters:))

Creates an object detector with a data table.

### Evaluating an object detector

[`evaluation(on:)`](/documentation/CreateML/MLObjectDetector/evaluation(on:))

Generates metrics by evaluating the object detector’s performance using annotated images in a data source.

[`evaluation(on:imageColumn:annotationColumn:)`](/documentation/CreateML/MLObjectDetector/evaluation(on:imageColumn:annotationColumn:))

Generates metrics by evaluating the object detector’s performance using annotated images in a data table.

[`trainingMetrics`](/documentation/CreateML/MLObjectDetector/trainingMetrics)

Measurements of the object detector’s performance on the training dataset.

[`validationMetrics`](/documentation/CreateML/MLObjectDetector/validationMetrics)

Measurements of the object detector’s performance on the validation dataset.

### Testing an object detector

[`prediction(from:)`](/documentation/CreateML/MLObjectDetector/prediction(from:))

Locates objects in an image and generates an annotation for each object it detects.

[`predictions(from:)`](/documentation/CreateML/MLObjectDetector/predictions(from:))

Locates objects in an array of images and generates an array of annotation collections, one for each input image.

[`MLObjectDetector.DetectedObjects`](/documentation/CreateML/MLObjectDetector/DetectedObjects)

An array of annotations that represent the items an object detector found in an image.

[`MLObjectDetector.ObjectAnnotation`](/documentation/CreateML/MLObjectDetector/ObjectAnnotation)

The label, location, and confidence score of an item the object detector found in an image.

### Saving an object detector

[`write(to:metadata:)`](/documentation/CreateML/MLObjectDetector/write(to:metadata:))

Exports the object detector as a Core ML model file.

[`write(toFile:metadata:)`](/documentation/CreateML/MLObjectDetector/write(toFile:metadata:))

Exports the object detector as a Core ML model file.

### Inspecting an object detector model

[`model`](/documentation/CreateML/MLObjectDetector/model)

The object detector’s underlying Core ML model instance.

[`modelParameters`](/documentation/CreateML/MLObjectDetector/modelParameters-swift.property)

The model configuration parameters the object detector used during its training session.

### Describing an object detector

[`description`](/documentation/CreateML/MLObjectDetector/description)

A text representation of the object detector.

[`debugDescription`](/documentation/CreateML/MLObjectDetector/debugDescription)

A text representation of the object detector that’s suitable for output
during debugging.

[`playgroundDescription`](/documentation/CreateML/MLObjectDetector/playgroundDescription)

A description of the object detector within a playground.

### Supporting types

[`MLObjectDetector.DataSource`](/documentation/CreateML/MLObjectDetector/DataSource)

A data source for an object detector.

[`MLObjectDetector.AnnotationType`](/documentation/CreateML/MLObjectDetector/AnnotationType)

The available types of image annotations.

[`MLObjectDetector.ModelParameters`](/documentation/CreateML/MLObjectDetector/ModelParameters-swift.struct)

Parameters that affect the process of training an object detection model.



---

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)